注销后如何使Perl脚本在Unix上运行? [英] How do I keep a Perl script running on Unix after I log off?

查看:115
本文介绍了注销后如何使Perl脚本在Unix上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的脚本要花很多时间才能完成.

我宁愿注销并稍后再获取其输出,而不是等待它完成.

我已经尝试过了

at -m -t 03030205 -f /path/to/./thescript.pl

nohup /path/to/./thescript.pl &

而且我还验证了这些进程实际上与psat -l存在,具体取决于我使用的调度语法.

当我退出shell时,这两个进程都会死掉.当我关闭连接时,有没有一种方法可以阻止脚本终止?

我们这里有cron,它们已经设置好并且可以正常工作,但是我想对单次使用脚本使用atnohup.

我的语法有问题吗?还有其他方法可以产生理想的结果吗?



我不能使用screendisown-在我的HP Unix设置中未安装它们,也无法安装它们

解决方案

这只是一个猜测,但是我已经在某些版本的ssh和nohup中看到了一些东西:如果您已经使用ssh登录,则可能需要需要重定向stdout,stderr stdin,以避免退出时会话挂起. (其中之一可能仍会连接到终端.)我会尝试:

nohup /path/to/./thescript.pl > whatever.stdout 2> whatever.stderr < /dev/null &

(我当前的ssh和nohup版本不再是这种情况-后者会在检测到终端上有附件时重定向它们-但您可能使用的是其他版本.)

I have a script that takes a lot of time to complete.

Instead of waiting for it to finish, I'd rather just log out and retrieve its output later on.

I've tried;

at -m -t 03030205 -f /path/to/./thescript.pl

nohup /path/to/./thescript.pl &

And I have also verified that the processes actually exist with ps and at -l depending on which scheduling syntax i used.

Both these processes die when I exit out of the shell. Is there a way to keep a script from terminating when I close the connection?

We have crons here and they are set up and are working properly, but I would like to use at or nohup for single-use scripts.

Is there something wrong with my syntax? Are there any other methods to producing the desired outcome?


EDIT:
I cannot use screen or disown - they aren't installed in my HP Unix setup and i am not in the position to install them either

解决方案

This is just a guess, but something I've seen with some versions of ssh and nohup: if you've logged in with ssh then you may need to need to redirect stdout, stderr and stdin to avoid having the session hang when you exit. (One of those may still be attached to the terminal.) I would try:

nohup /path/to/./thescript.pl > whatever.stdout 2> whatever.stderr < /dev/null &

(This is no longer the case with my current versions of ssh and nohup - the latter redirects them if it detects that any is attached to a terminal - but you may be using different versions.)

这篇关于注销后如何使Perl脚本在Unix上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆