[lug] cron and date command
D. Frye
dafr at dafr.us
Wed Mar 8 12:59:44 MST 2006
On Wed, Mar 08, 2006 at 02:36:52PM -0500, Gordon Golding wrote:
} I want to run a backup script and feed it today's date. I know I can change the script and be OK, but I'm wondering about this problem.
} I'm on Fedora Core 3.
}
} If I use `date +%y%m%d` it works fine from the command line. But I run the same command in cron and it doesn't run - it doesn't create the log or err files or run the script.
}
} Neither of these 2 entries work. This example runs it hourly for testing. In the second example it doesn't work either as a parameter or part of the file name.
}
} 0 * * * * BACKUPNAME=name`date +%y%m%d`
} 0 * * * * /home/BACKUPS/Backup_to_Disk2.bsh name`date +%y%m%d` 1>/home/BACKUPS/name`date +%y%m%d`.log 2>/home/BACKUPS/name`date +%y%m%d`.err
}
}
Gordon,
My recollection is that the '%' is a reserved character in the crontab
file. This is based on a problem that I was bitten by back in 2001, and
I don't recall where I found the information at. You *might* be able to
use the standard backslash to escape the character and have it treated
as a literal.
David
--
D. Frye
dafr AT dafr.us
http://www.dafr.us/dafr
More information about the LUG
mailing list