Can someone point me to a reference for cron on centos 6. Root's crontab isn't getting run at all and comparing the cron config w/ CentOS 5 is pointless as it appears to be configured entirely differently.
Here's my current crontab for root:
# crontab -l
0 2 * * * su -l postgres -c 'pg_dumpall -O -f /home/backup/postgres-`date +%a`-dump.sql'
0 3 * * * tar cPjf /home/backup/iwiki-`date +%a`-html-files.bz2 /var/www/html/wiki.viviotech.net/
I can run these on the cli just fine.
# cat /etc/redhat-release
CentOS Linux release 6.0 (Final)
# uname -a
Linux kingsholly.viviotech.net 2.6.32-71.29.1.el6.x86_64 #1 SMP Mon Jun 27 19:49:27 BST 2011 x86_64 x86_64 x86_64 GNU/Linux
# yum list \*cron\*
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
* base: mirror.web-ster.com
* extras: mirrors.cat.pdx.edu
* updates: mirrors.cat.pdx.edu
Installed Packages
cronie.x86_64 1.4.4-2.el6 @base
cronie-anacron.x86_64 1.4.4-2.el6 @base
crontabs.noarch 1.10-32.1.el6 @base
Available Packages
PackageKit-cron.x86_64 0.5.8-13.el6 base
cronie-noanacron.x86_64 1.4.4-2.el6 base
rpm-cron.noarch 4.8.0-12.el6 base
Root cron doesn't work
Re: Root cron doesn't work
From `man 5 crontab`
[quote]
The "sixth" field (the rest of the line) specifies the command to be run. The entire
command portion of the line, up to a newline or % character, will be executed by
/bin/sh or by the shell specified in the SHELL variable of the cronfile. Percent-
signs (%) in the command, unless escaped with backslash (\), will be changed into
newline characters, and all data after the first % will be sent to the command as
standard input.
[/quote]
Both your commands have embedded % signs so need to be escaped.
[quote]
The "sixth" field (the rest of the line) specifies the command to be run. The entire
command portion of the line, up to a newline or % character, will be executed by
/bin/sh or by the shell specified in the SHELL variable of the cronfile. Percent-
signs (%) in the command, unless escaped with backslash (\), will be changed into
newline characters, and all data after the first % will be sent to the command as
standard input.
[/quote]
Both your commands have embedded % signs so need to be escaped.
Re: Root cron doesn't work
Welcome to the CentOS fora.
On top of [b]Trevor[/b]'s remark, you may also want to consider specifying the full pathnames to the binaries, i.e.
/bin/su
and
/bin/tar
While it may not be required here, it is good practice to do so for cron, as the normal login environment is not set.
As a side note:
[quote]frogstarr78 wrote:
# uname -a
Linux kingsholly.viviotech.net 2.6.32-71.29.1.el6.x86_64 #1 SMP Mon Jun 27 19:49:27 BST 2011 x86_64 x86_64 x86_64 GNU/Linux[/quote]
You are running an old kernel, current kernel is
[code]$ uname -r
2.6.32-131.17.1.el6.x86_64[/code]
You likely have not configured the [url=http://wiki.centos.org/AdditionalResources/Repositories/CR]CR repository[/url], which would update you to 6.1
On top of [b]Trevor[/b]'s remark, you may also want to consider specifying the full pathnames to the binaries, i.e.
/bin/su
and
/bin/tar
While it may not be required here, it is good practice to do so for cron, as the normal login environment is not set.
As a side note:
[quote]frogstarr78 wrote:
# uname -a
Linux kingsholly.viviotech.net 2.6.32-71.29.1.el6.x86_64 #1 SMP Mon Jun 27 19:49:27 BST 2011 x86_64 x86_64 x86_64 GNU/Linux[/quote]
You are running an old kernel, current kernel is
[code]$ uname -r
2.6.32-131.17.1.el6.x86_64[/code]
You likely have not configured the [url=http://wiki.centos.org/AdditionalResources/Repositories/CR]CR repository[/url], which would update you to 6.1
-
- Posts: 4
- Joined: 2011/11/24 04:18:05
Re: Root cron doesn't work
[quote]
r_hartman wrote:
Welcome to the CentOS fora.
On top of [b]Trevor[/b]'s remark, you may also want to consider specifying the full pathnames to the binaries, i.e.
/bin/su
and
/bin/tar
While it may not be required here, it is good practice to do so for cron, as the normal login environment is not set.
[/quote]
IDK, I trust that the PATH set in /etc/crontab will do what I expect
[code]PATH=/sbin:/bin:/usr/sbin:/usr/bin[/code]
r_hartman wrote:
Welcome to the CentOS fora.
On top of [b]Trevor[/b]'s remark, you may also want to consider specifying the full pathnames to the binaries, i.e.
/bin/su
and
/bin/tar
While it may not be required here, it is good practice to do so for cron, as the normal login environment is not set.
[/quote]
IDK, I trust that the PATH set in /etc/crontab will do what I expect
[code]PATH=/sbin:/bin:/usr/sbin:/usr/bin[/code]
-
- Posts: 4
- Joined: 2011/11/24 04:18:05
Re: Root cron doesn't work
[quote]
TrevorH wrote:
From `man 5 crontab`
[quote]
The "sixth" field (the rest of the line) specifies the command to be run. The entire
command portion of the line, up to a newline or % character, will be executed by
/bin/sh or by the shell specified in the SHELL variable of the cronfile. Percent-
signs (%) in the command, unless escaped with backslash (\), will be changed into
newline characters, and all data after the first % will be sent to the command as
standard input.
[/quote]
Both your commands have embedded % signs so need to be escaped.[/quote]
Huh! Good to know. Thanx.
TrevorH wrote:
From `man 5 crontab`
[quote]
The "sixth" field (the rest of the line) specifies the command to be run. The entire
command portion of the line, up to a newline or % character, will be executed by
/bin/sh or by the shell specified in the SHELL variable of the cronfile. Percent-
signs (%) in the command, unless escaped with backslash (\), will be changed into
newline characters, and all data after the first % will be sent to the command as
standard input.
[/quote]
Both your commands have embedded % signs so need to be escaped.[/quote]
Huh! Good to know. Thanx.
-
- Posts: 4
- Joined: 2011/11/24 04:18:05
Re: Root cron doesn't work
[quote]
r_hartman wrote:
As a side note:
[quote]frogstarr78 wrote:
# uname -a
Linux kingsholly.viviotech.net 2.6.32-71.29.1.el6.x86_64 #1 SMP Mon Jun 27 19:49:27 BST 2011 x86_64 x86_64 x86_64 GNU/Linux[/quote]
You are running an old kernel, current kernel is
[code]$ uname -r
2.6.32-131.17.1.el6.x86_64[/code]
You likely have not configured the [url=http://wiki.centos.org/AdditionalResources/Repositories/CR]CR repository[/url], which would update you to 6.1[/quote]
Thanx for the CR Repository suggestion too.
r_hartman wrote:
As a side note:
[quote]frogstarr78 wrote:
# uname -a
Linux kingsholly.viviotech.net 2.6.32-71.29.1.el6.x86_64 #1 SMP Mon Jun 27 19:49:27 BST 2011 x86_64 x86_64 x86_64 GNU/Linux[/quote]
You are running an old kernel, current kernel is
[code]$ uname -r
2.6.32-131.17.1.el6.x86_64[/code]
You likely have not configured the [url=http://wiki.centos.org/AdditionalResources/Repositories/CR]CR repository[/url], which would update you to 6.1[/quote]
Thanx for the CR Repository suggestion too.
-
- Retired Moderator
- Posts: 18276
- Joined: 2006/12/13 20:15:34
- Location: Tidewater, Virginia, North America
- Contact:
Root cron doesn't work
[quote]
frogstarr78 wrote:
...
IDK, I trust that the PATH set in /etc/crontab will do what I expect
[code]PATH=/sbin:/bin:/usr/sbin:/usr/bin[/code][/quote]
That PATH applies only to entries in that file. The environment for user crontab entries in /var/spool/cron/ is different. To see it, try the following entry in a user crontab created by "crontab -e":[code]* * * * * echo $PATH > /tmp/test.txt[/code]That will update /tmp/test.txt with the current path every minute. I get[code]$ cat /tmp/test.txt
/usr/bin:/bin[/code]
frogstarr78 wrote:
...
IDK, I trust that the PATH set in /etc/crontab will do what I expect
[code]PATH=/sbin:/bin:/usr/sbin:/usr/bin[/code][/quote]
That PATH applies only to entries in that file. The environment for user crontab entries in /var/spool/cron/ is different. To see it, try the following entry in a user crontab created by "crontab -e":[code]* * * * * echo $PATH > /tmp/test.txt[/code]That will update /tmp/test.txt with the current path every minute. I get[code]$ cat /tmp/test.txt
/usr/bin:/bin[/code]