![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| cron job starts new cron proccess | ron76 | SUN Solaris | 3 | 05-12-2008 02:07 AM |
| Cron and Pseudo-Cron | dingusmcghee | UNIX for Dummies Questions & Answers | 1 | 01-31-2008 12:58 PM |
| CRON usage for CRON job | skyineyes | UNIX for Dummies Questions & Answers | 1 | 01-17-2008 10:17 AM |
| AIX and cron logs filtering ?: /etc/cronlog.conf, /var/adm/cron/log | Keith Johnson | AIX | 0 | 01-09-2008 08:32 PM |
| Cron : you are not authorized to use cron. Sorry. | tt155 | UNIX for Advanced & Expert Users | 1 | 07-06-2005 11:37 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Cron
Could someone advise of the code to get a filename to have the date of creation in it?
I've the code to dump an SQL DB to a file, but would like it to have the date it. Also, what is the code to get cron to execute a PHP (or perl) script at a set time? Thanks, Ed Ludlow |
|
||||
|
For building a name with a datestamp, you can refer to what I have tried, quoted below, in the past in my auto build script. Just use the date command to formulate a date string: Code:
TODAY=`date +%Y%m%d` This creates a string like '20040602', which you can attach to the end of a fixed filename to create the final filename, like Code:
mysql_$TODAY.sql If you need to construct the date string in PHP, please consult the PHP manual. As for invoking a PHP script from the command line, it should be as easy as something like php script.php perl script.pl Just place this at the end of the cron line in place of the command to be executed. |
|
||||
|
OK. Still having problems
![]() So the first line of my crontab is: TODAY=$(date +%d%m%Y) and the filenamr part of the cron command is: backup$TODAY.sql So what is wrong? That returns the filename: backup$(date +%d%m%Y).sql Thanks, Ed |
|
||||
|
Works for me in ksh. Are you sure you are using ksh? If not, as google mentioned do: Code:
TODAY=`date +%Y%m%d` It's also good practice when using a variable without spaces next to the next character to enclose in curly brackets. So your cron code would look like: Code:
backup${TODAY}.sql
|
|
||||
|
It's now returning
backup{`date +%d%m%Y`}.sql as the filename!!!!! I'm a newbie to Unix, so I hope I'm write in saying the declaration of the variable should go on the first line of the file that opens when you type "crontab -e"??? How do I find out if this is ksh or whatever? Thanks, Ed |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|