Sample Header Ad - 728x90

how make nohup log command it self

0 votes
0 answers
39 views
I use nohup like:
nohup ./cmd.sh --para=abc > ${PWD}/cmd_$(date "+%Y%m%d_%H%M_%S").log 2>&1 &
How can I make the output log file include the command itself, i.e. the ./cmd.sh --para=abc > ${PWD}/cmd_$(date "+%Y%m%d_%H%M_%S").log part could be found in the log file (say cmd_20241030_1315_00.log). And any of the followings would be ok:
nohup ./cmd.sh --para=abc > ${PWD}/cmd_$(date "+%Y%m%d_%H%M_%S").log 2>&1 &

nohup ./cmd.sh --para=abc > /real/path/cmd_20241030_1315_00.log

./cmd.sh --para=abc > /real/path/cmd_20241030_1315_00.log

./cmd.sh --para=abc
Asked by furynerd (21 rep)
Oct 31, 2024, 01:31 AM
Last activity: Oct 31, 2024, 09:55 AM