Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Cron jobs

Status
Not open for further replies.

mks6376

IS-IT--Management
Jul 5, 2005
20
US
Hi,
I have submitted a cron job to run every minute. I don't know if it is running or not.
Is there a way I can check that. Do I have to do something after submitting a job to make it run.
The line I added into crontab is

1 * * * * /usr/sbin/ntpdate -s -b -p 8 -u x.x.x.x

(where x.x.x.x is an IP address)

Please help

Thanks
 
Your job only runs every 1st minute of an hour.
To run every minute, you have to write "* * * * * /usr/...".
The logfile for cron is (as far as I remember) /var/cron/log.

Huebs
===
 
Why would you run ntpdate every minute? Once an hour shoud be sufficient.

But if you want it to run every minute, then replace your line with:

Code:
0-60 * * * * /usr/sbin/ntpdate -s -b -p 8 -u x.x.x.x
 
Thanks a lot for the suggestion.
That made my cron job work. But I think ntpdate command cannot be executed by other than root. Thus the job was giving me permission denied in the logs.

Thanks
 
I would eventually be running it once a day. Its just for testing purpose I wanted to do that.

Is it necessary to run the ntpdate command with the root previlage? If I submit the job with a non-root user it gives the error permission denined.

THanks
 
Yes, only root has access to update the system clock.

You should really set up /etc/inet/ntp.conf and run xntpd instead of running ntpdate manually.

Annihilannic.
 
Just a small point - shouldn't the 0-60 in kHz's post be 0-59 to run every minute?
 
I have set up /etc/inet/ntp.conf and xntpd is running. But I am not sure how often this would sync the system clock. Also if I restart the XNTP daemon it doesn't sync the clock.

Thanks
 
I think it does so once every 70 seconds or something strange like that... but it only adjusts it in tiny steps so that your applications aren't confused by sudden changes in time. If your clock is too far out of line (more than 1000 seconds or something?) it will just give up and quit after a short while, so it's a good idea to run ntpdate once just before starting it if that's the case.

Annihilannic.
 
Use "ntpq -p" to see how and when xntpd syncs your clock. Column "poll" is the polling interval in secs, "offset" is the time offset in msecs.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top