Linux - Newbie This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
|
 |
04-01-2005, 10:53 PM
|
#1
|
LQ Newbie
Registered: Mar 2005
Location: Waltham, MA
Distribution: SUSE 9.1
Posts: 15
Rep:
|
cron problems
Hi, I am trying to synchronize my clock every hour through a cron job.
'crontab -u root -l' gives me:
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.12634 installed on Mon Jan 1 12:25:32 2001)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
26 * * * * /usr/sbin/ntpdate north-america.pool.ntp.org
yet it does not work, but I am sure the ntpdate command is working because I can run it from the command line.
I think the cron dameon is running beacuse 'ps aux|grep cron' gives me:
root 12013 0.8 0.2 1400 596 ? Ss 11:54 0:22 cron
root 12902 0.0 0.1 1520 484 pts/0 R+ 12:37 0:00 grep cron
Am I overlooking anything?
Thanks in advance.
|
|
|
04-02-2005, 01:01 AM
|
#2
|
Member
Registered: Feb 2004
Location: Utah, USA
Distribution: Debian
Posts: 230
Rep:
|
Not sure if you're overlooking something, but here is how I handle mine on Slackware 10.1 (running 'crontab -e' doesn't work for me - something to do with my editor settings).
As root I do the following:
cd /var/spool/cron/crontabs/
vi cron_holder (make entries/edits, save changes)
crontab cron_holder
This creates a cron.update file in the same directory that gets processed on the next cron cycle (not sure if I'm explaining it right) and copies your changes into the 'root' file which is run by cron - editing the 'root' file directly is a bad idea and the changes won't go into affect.
Hope that helps.
|
|
|
04-02-2005, 05:33 AM
|
#3
|
Member
Registered: Aug 2004
Location: Australia
Distribution: Fedora
Posts: 282
Rep:
|
Well, I think you can always edit the cron job by simply using 'crontab -e'.
If you want to schedule the job as root or someone, you can su to root (or that someone else) before you do 'crontab -e'
As for tassinari's issue, my guess is the cron job definition does not like the space in the command. Try wrap this command in a shell script.
i.e. put the lines
Code:
#!/bin/bash
/usr/sbin/ntpdate north-america.pool.ntp.org
into, says, time.sh (make sure the x permission are set on this file)
then crontab -e and change the line into
Code:
26 * * * * /path/to/time.sh
Hopefully it works.
|
|
|
04-02-2005, 06:16 AM
|
#4
|
Member
Registered: May 2004
Location: Karlsruhe, Germany
Distribution: debian, gentoo, os x (darwin), ubuntu
Posts: 940
Rep:
|
what are the mails your crontab retuns?
if you dont have any: add this to your crontab in the first line (just for debug purposes!)
MAILTO=you@example.com
|
|
|
04-02-2005, 10:47 AM
|
#5
|
LQ Newbie
Registered: Mar 2005
Location: Waltham, MA
Distribution: SUSE 9.1
Posts: 15
Original Poster
Rep:
|
Thanks to everyone for their help but the problem fixed itself. I woke this morning and started the computer and the cron job ran. I changed nothing from last night. My guess is the cron dameon wasn't working last night but did work this morning after booting. Why it was'nt working last night is beyond me though.
Thanks again!
|
|
|
04-02-2005, 11:52 AM
|
#6
|
Member
Registered: Feb 2004
Location: Utah, USA
Distribution: Debian
Posts: 230
Rep:
|
Linux = when all else fails, reboot
Windows = first step, reboot
|
|
|
04-02-2005, 03:46 PM
|
#7
|
Member
Registered: Aug 2004
Location: Australia
Distribution: Fedora
Posts: 282
Rep:
|
When, in this case, you do not have to reboot either... :-)
If you are confident that your job definition is fine but it's justing not running, you may try
first to check if there is any crond processes stalled.
I saw this kind of problem before. If it is the case, kill the crond and that's. No need to reboot.
|
|
|
04-02-2005, 05:06 PM
|
#8
|
Senior Member
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,852
|
Re: cron problems
Quote:
Hi, I am trying to synchronize my clock every hour through a cron job.
Am I overlooking anything?
|
I'm wondering whether setting up the NTP service wouldn't be easier than the cron job. Yes, you do need to track down a suitable time server (see the lists on http://ntp.isc.org/bin/view/Servers/WebHome) but once that's done it's pretty much "set and forget".
|
|
|
04-02-2005, 10:11 PM
|
#9
|
Member
Registered: Aug 2004
Location: Australia
Distribution: Fedora
Posts: 282
Rep:
|
rnturn is right. I'd overlooked the real issue.
|
|
|
All times are GMT -5. The time now is 04:07 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|