| Author |
Message |
Shoie13
Joined: 29 Apr 2009
Posts: 10
|
| Posted: Sun Feb 14, 2010 5:06 am Post subject: Crontab and Tar Backups |
|
|
I created a crontab using the crontab -e command, inserting:
Code:
55 4 * * * tar -czvf backups/mud/main/swgi`date +%Y-%m-%d`.tgz swgi 2>&1 >> log/cron.log
4:55 comes and goes and the job never executes and nothing is written to the log file. I never tried adding any scripts to the cron directories in /etc, I suppose that would be the next step. Cron IS running:
Code:
root 1491 0.0 0.1 2048 892 ? Ss Feb08 0:00 /usr/sbin/cron
So I assume that perhaps I missed something? Any ideas? |
|
| Back to top |
|
sednet
Joined: 17 Mar 2004
Posts: 157
Location: Europe
|
| Posted: Sun Feb 14, 2010 5:23 am Post subject: Re: Crontab and Tar Backups |
|
|
Shoie13 wrote: I created a crontab using the crontab -e command, inserting:
Code:
55 4 * * * tar -czvf backups/mud/main/swgi`date +%Y-%m-%d`.tgz swgi 2>&1 >> log/cron.log
You are merging the stderr into the stdout then redirecting the stdout. This should be the other way around. i.e. command >>log/cron.log 2>&1
Maybe the output is getting mailed to you instead and you are never seeing it.
It would be a good idea to use full paths for 'swgi' and 'log/cron.log' too.
If this job really isn't running you should check /etc/cron.allow and /etc/cron.deny. See man crontab. |
|
| Back to top |
|
Shoie13
Joined: 29 Apr 2009
Posts: 10
|
| Posted: Sun Feb 14, 2010 5:40 am Post subject: |
|
|
Code:
/bin/sh: -c: line 0: unexpected EOF while looking for matching ``'
/bin/sh: -c: line 1: syntax error: unexpected end of file
What would that errror mean? The command runs fine when I use it. |
|
| Back to top |
|
glg
Joined: 09 Jan 2009
Posts: 452
|
| Posted: Sun Feb 14, 2010 11:10 am Post subject: |
|
|
I've found it's better to write commands like that into a shell script. Test the shell script, make sure it works. Then call the shell script from cron.
As sednet says, it's usually a good idea to use explicit paths as well instead of relative paths. |
|
| Back to top |
|
Shoie13
Joined: 29 Apr 2009
Posts: 10
|
| Posted: Mon Feb 15, 2010 2:23 pm Post subject: |
|
|
glg wrote: I've found it's better to write commands like that into a shell script. Test the shell script, make sure it works. Then call the shell script from cron.
That solved the problem and works beautifully. Much thanks. |
|
| Back to top |
|
| |