Operating System - HP-UX
1753797 Members
7291 Online
108805 Solutions
New Discussion юеВ

redirecting output from crontab script

 
SOLVED
Go to solution
MikeL_4
Super Advisor

redirecting output from crontab script

I am trying to create a log file from an ignite recovery script with the date appended to it with following crontab entry:
# Ignite Backup
00 06 * * 0 /root/make_net_recovery.ksh > /root/`hostname`_net_recovery.log.`dat
e "+%Y%m%d_%H%M"` 2>&1

It created a log file with the servername_net_recovery.log. but did not append the date to the end as I had hoped.

3 REPLIES 3
Jean-Luc Oudart
Honored Contributor

Re: redirecting output from crontab script

Hi Mike,

May be you should put the command in a specific script :
H1=${hostname}
D1=$(date "+%Y%m%d_%H%M"}
LOGFILE=/root/$H1_net_recovery.log$D1
then your command

Alos ensure that your PATH has access to all commands.

Regards
Jean-Luc
fiat lux
Sridhar Bhaskarla
Honored Contributor
Solution

Re: redirecting output from crontab script

Hi,

Escape % character. For ex., date +\%Y\%m etc.,

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
MikeL_4
Super Advisor

Re: redirecting output from crontab script

Thanks