这几天在linux服务器上跑程序。
在perl 文件中,会相继调用几个system产生子进程。
-------------example.pl---------
chdir "/home/";
system 'perl ./1.pl';
system 'perl ./2.pl';
system 'perl ./3.pl';
------------------------
比如用screen跑着example.pl中的1.pl。我现在想1.pl接着跑,但让1.pl跑完后,不再跑2.pl了。
可以通过kill (pid of example.pl)来实现,但是如果只在screen的父进程tty中kill掉example.pl,那么会kill掉整个screen,1.pl也就停止了。
所以应该在screen中kill example.pl就不会有问题了。
note:
使用screen启动程序分三种情况(网上有相应的文章)
1. screen example.pl
2. screen 进入新的窗口后,再输入命令example.pl
3. 在screen中建多窗口
应该使用第2种方法!来启动example.pl。
使用第1种会在程序运行完的时候直接退出screen.