遇到一个棘手的需求,需要在后端跑到爬虫进程
刚开始是这样的,在后面加 &
$ ./test.sh &
关掉shell依然后kill掉进程,后来发现其父进程还是当前终端shell的进程,而一旦父进程退出,则会发送hangup信号给所有子进程,子进程收到hangup以后也会退出。如果要在退出shell的时候继续运行进程,则需要使用nohup忽略hangup信号,或者setsid将将父进程设为init进程(进程号为1)
详细代码是这样的:
$nohup ./test.sh & $echo $$ 21734 $ nohup ./test.sh & [1] 29016 $ ps -ef | grep test 515 29710 21734 0 11:47 pts/12 00:00:00 /bin/sh ./test.sh 515 29713 21734 0 11:47 pts/12 00:00:00 grep test $ setsid ./test.sh & [1] 409 $ ps -ef | grep test 515 410 1 0 11:49 ? 00:00:00 /bin/sh ./test.sh 515 413 21734 0 11:49 pts/12 00:00:00 grep test
安装screen
yum install -y screen
输入screen,然后输入你要运行的命令
ctrl+A 然后按D,screen会关闭
查看正在运行的程序
screen -ls
You have noted very interesting points! ps nice website . “Where can I find a man governed by reason instead of habits and urges” by Kahlil Gibran.
Terrific work! This is the type of information that should be shared around the internet. Shame on the search engines for not positioning this post higher! Come on over and visit my web site . Thanks =)
I always was interested in this topic and still am, thanks for putting up.
I’m not sure exactly why but this website is loading extremely slow for me. Is anyone else having this problem or is it a problem on my end? I’ll check back later and see if the problem still exists.|
خرید فالوور خرید فالوور خرید فالوور خرید فالوور خرید فالوور خرید فالوور خرید فالوور
cialis porn animal hacklink buy google.
tiktok follower kaufen
Wow, fantastic blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your site is fantastic, let alone the content!
buy hacklink and viagra instagram shop best buy site.
buy hacklink and viagra instagram shop best buy site.
Hi there friends, how is all, and what you would like to say concerning this piece of writing, in my view its actuallyamazing designed for me.
When some one searches for his required thing, therefore he/she wants to be available that in detail, thus that thing is maintained over here.
Hi Dear, are you actually visiting this web page daily, if so then you will definitelyget pleasant experience.
buy animal porn instagram web site.
buy animal porn instagram web site.
buy animal porn instagram web site.
buy animal porn instagram web site.