nohup VERBOSE=1 perl script.pl

拈花ヽ惹草 提交于 2019-11-30 16:38:31

问题


I have a perl script for which ENV variables can be set to direct specific outputs e.g. $debug, $verbose, $develop etc

Usually I run these from the command line

$ VERBOSE=1 perl myperlscript.pl params

I now want to run them using nohup. Using the command line

$ nohup VERBOSE=1 perl myperlscript.pl params 

is clearly not right, as the attempt to set ENV{VERBOSE} is interpreted as a param to nohup & I get the msg

nohup: failed to run command `VERBOSE=1': No such file or directory

What IS the correct syntax here? I'm trying to run this on a linux box.


回答1:


Set the environment variable before calling nohup, and it will be preserved when nohup exec()s (replaces itself with) perl.

$ VERBOSE=1 nohup perl myscript.pl params ...



回答2:


This is exactly what the env command is for:

$ env VAR1=VAL1 VAR2=VAL2 nohup perl myperlscript.pl params &



回答3:


Try to combine all commands into shell script and run it like that: nohup /path/to/script.sh

Or you could use export: export VERBOSE=1 And then: nohup perl myperlscript.pl params



来源:https://stackoverflow.com/questions/8825460/nohup-verbose-1-perl-script-pl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!