Reputation: 493
I am trying to run a command with nohup
, for example
nohup python -u myscript.py --lots --of --options 1000 &> logfile.out
Is there any way to write the command as the first line of logfile.out
? For example,
python -u myscript.py --lots --of --options 1000
Script running...
Script complete!
Upvotes: 0
Views: 189
Reputation: 785058
You can use a function for this:
runbg() {
out="$1"
shift
printf "%s\nScript Runinng...\n" "$*" > "$out"
nohup "$@" &>> "$out" &
}
Then run it as:
runbg logfile.out python -u myscript.py --lots --of --options 1000
Upvotes: 0
Reputation: 42007
You can create a wrapper function nohup
:
nohup () { echo "$@"; command nohup "$@" ;}
Now if you do:
nohup python -u myscript.py --lots --of --options 1000 &> logfile.out
you'll get the desired command line saved along with other regular STDOUT/STDERR on logfile.out
.
Upvotes: 1