Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi everyone,
I'm configuring a crontab in my new host and it shows the following messages on the /var/log/cron:
Code:
Jun 27 06:07:01 SERVER CROND[12059]: (root) CMD (root /usr/sbin/ntpdate ntp0 > /dev/null 2>&1)
Jun 27 06:07:01 SERVER CROND[12060]: (root) CMD (/usr/sbin/ntpdate ntp0 > /dev/null 2>&1)
Jun 27 07:01:01 SERVER CROND[12641]: (root) CMD (run-parts /etc/cron.hourly)
Jun 27 07:01:01 SERVER run-parts(/etc/cron.hourly)[12641]: starting 0anacron
Jun 27 07:01:01 SERVER run-parts(/etc/cron.hourly)[12650]: finished 0anacron
as you can see, is executing two times...and I donīt know the reason...
OS:
Red Hat Enterprise Linux Server release 6.9 (Santiago)
Permisions on the file:
Code:
-rw-r--r-- 1 root root 93 Jun 6 13:58 ntp
I check other hosts, not configuring by me, and show the following log:
Code:
Jun 27 05:00:01 SERVER crond[823]: (*system*) NULL security context for user, but SELinux in permissive mode, continuing ()
Jun 27 05:00:01 SERVER crond[824]: (root) CMD (/usr/sbin/ntpdate ntp0 >/dev/null)
Jun 27 05:01:01 SERVER crond[1713]: (*system*) NULL security context for user, but SELinux in permissive mode, continuing ()
Jun 27 05:01:01 SERVER crond[1714]: (root) CMD (run-parts /etc/cron.hourly)
Hi everyone,
I'm configuring a crontab in my new host and it shows the following messages on the /var/log/cron:
Code:
Jun 27 06:07:01 SERVER CROND[12059]: (root) CMD (root /usr/sbin/ntpdate ntp0 > /dev/null 2>&1)
Jun 27 06:07:01 SERVER CROND[12060]: (root) CMD (/usr/sbin/ntpdate ntp0 > /dev/null 2>&1)
Jun 27 07:01:01 SERVER CROND[12641]: (root) CMD (run-parts /etc/cron.hourly)
Jun 27 07:01:01 SERVER run-parts(/etc/cron.hourly)[12641]: starting 0anacron
Jun 27 07:01:01 SERVER run-parts(/etc/cron.hourly)[12650]: finished 0anacron
as you can see, is executing two times...and I donīt know the reason...
Although we do not have all of the cron log entries and making a few assumptions but if the OP put their ntp script in cron.hourly there would be a log entry like.
Quote:
Jun 27 07:01:01 SERVER run-parts(/etc/cron.hourly)[12641]: starting ntp
Jun 27 07:01:01 SERVER run-parts(/etc/cron.hourly)[12650]: finished ntp
Quote:
Jun 27 06:07:01 SERVER CROND[12059]: (root) CMD (root /usr/sbin/ntpdate ntp0 > /dev/null 2>&1)
This would indicate a cron.d or a users cron job.
Quote:
(root /usr/sbin/ntpdate ntp0 > /dev/null 2>&1)
This is the command that cron will run. System cron jobs require a run as user but a regular user's does not.
Since root shows up in the command it typically means that there is a root cron job.
This is the command that cron will run. System cron jobs require a run as user but a regular user's does not.
Since root shows up in the command it typically means that there is a root cron job.
Ahh. I wondered what the difference was between these:
Code:
Jun 27 06:07:01 SERVER CROND[12059]: (root) CMD (root /usr/sbin/ntpdate ntp0 > /dev/null 2>&1)
Jun 27 06:07:01 SERVER CROND[12060]: (root) CMD (/usr/sbin/ntpdate ntp0 > /dev/null 2>&1)
So the first indicates the user root's crontab, and the second is from /etc/cron.d/ntp -- right?
The OP is apparently logged in as root, so when he does
Code:
crontab -l
he is seeing the second cron, yes?
Then he should probably just
[root@HOST~]# cat /etc/cron.hourly/0anacron
#!/bin/bash
# Skip excecution unless the date has changed from the previous run
if test -r /var/spool/anacron/cron.daily; then
day=`cat /var/spool/anacron/cron.daily`
fi
if [ `date +%Y%m%d` = "$day" ]; then
exit 0;
fi
# Skip excecution unless AC powered
if test -x /usr/bin/on_ac_power; then
/usr/bin/on_ac_power &> /dev/null
if test $? -eq 1; then
exit 0
fi
fi
/usr/sbin/anacron -s
Quote:
Originally Posted by scasey
Ahh. I wondered what the difference was between these:
Code:
Jun 27 06:07:01 SERVER CROND[12059]: (root) CMD (root /usr/sbin/ntpdate ntp0 > /dev/null 2>&1)
Jun 27 06:07:01 SERVER CROND[12060]: (root) CMD (/usr/sbin/ntpdate ntp0 > /dev/null 2>&1)
So the first indicates the user root's crontab, and the second is from /etc/cron.d/ntp -- right?
The OP is apparently logged in as root, so when he does
Code:
crontab -l
he is seeing the second cron, yes?
Then he should probably just
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.