Operating System - HP-UX
1825803 Members
2616 Online
109687 Solutions
New Discussion

Re: Script - capture log name

 
SOLVED
Go to solution
MikeL_4
Super Advisor

Script - capture log name

I have a crontab entry that creates a log file from sample entry:
00 07 * * 2 /root/make_net_recovery.ksh > /root/logs/`hostname`_net_recovery.log
.`date "+\%Y\%m\%d_\%H\%M"` 2>&1

Is there a way within the script to capture the name assigned to the log file thats being generated ?
3 REPLIES 3
Steven E. Protter
Exalted Contributor

Re: Script - capture log name

When a script is run the variable $0 is the name of the script being run.

In the script itself, echo $0 to the log file.

You could also route the output with a | mailx -s "script is run" someone@your.net

on the end of it.

I'd suggest this statement in the script

echo $0 >> /root/logs/`hostname`_net_recovery.log

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Geoff Wild
Honored Contributor
Solution

Re: Script - capture log name

Do you mean the cron log?

ls -tr /root/logs/*log* |tail -1

Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
MikeL_4
Super Advisor

Re: Script - capture log name

Thanks