Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
313 views
in Technique[技术] by (71.8m points)

linux - Custom command in WinSCP which creates a log file with timestamp at the time of file creation

I am running a hive script from within WinSCP (as it allows me to do simple edits to my file as well as run them using file custom commands or via the terminal).

Currently, I'm using the following as a custom command (just right clicking on the file and running this, makes the task very convenient):

nohup /location/platform/cloak/bin/cloak-hive -f ! >> script_temp.log 2>&1 &

which creates a log file the first time and for each subsequent run, the same file gets appended. Ideally I would want the log file to take the name from the ! pattern and expand it to filename.log. If that is not possible, I'd want to have a timestamp added to the filename.

Aim is to get different logs for different runs, but without changing the custom command each time. I have seen various solutions to append the timestamp after the file is created, but I need to get the name correct with the custom command itself for convenience and tracking. The server being accessed by WinSCP is running RHEL 7.8.

question from:https://stackoverflow.com/questions/65886311/custom-command-in-winscp-which-creates-a-log-file-with-timestamp-at-the-time-of

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

So use the ! pattern in the log name:

nohup /location/platform/cloak/bin/cloak-hive -f ! >> !.log 2>&1 &

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...