-
crontab time issues
Hi
I've added this line to /etc/crontab, the system wide crontab file.
0 0 * * * root /usr/sbin/ntpdate -o 1 tock.usno.navy.mil
NTPDate sync's my machine's time with the above server's time.
The next line in the same file is:
5 0 * * * root date | mail root@localhost
This e-mails me the time
So, after the time is sync'd, I get an e-mail. Perfect!
The problem is, I get an e-mail with the date at 0:00, and another one at 15:00. I've tested this with other lines in the /etc/crontab file ("echo "test at noon" |mail) and again, I get two e-mails.
Anyone else have this problem?
Anyone know how to stop this?
When I started crond, I just did "sudo /etc/init.d/cron start"
Thanks,
- Ambrose
-
Senior Member
registered user
Re: crontab time issues
--In the first line, you have '0 0 *...'
--Second line, you have '5 0 *...' so things aren't happening sequentially the way you expect.
--I am not a cron guru, but suggest you put the ntpdate and mail commands into 1 script file and then run that file at midnight+ 1minute (don't forget to chmod +x it.) This will ensure the mail only arrives after ntpdate runs, and only runs with that file.
--Also do ' ps ax |grep cron ' and see if you have two daemons running.
--Neat idea; thanx for the tip.
![Quote](images/misc/quote_icon.png)
Originally Posted by
Ambrose
Hi
I've added this line to /etc/crontab, the system wide crontab file.
0 0 * * * root /usr/sbin/ntpdate -o 1 tock.usno.navy.mil
NTPDate sync's my machine's time with the above server's time.
The next line in the same file is:
5 0 * * * root date | mail root@localhost
This e-mails me the time
So, after the time is sync'd, I get an e-mail. Perfect!
The problem is, I get an e-mail with the date at 0:00, and another one at 15:00. I've tested this with other lines in the /etc/crontab file ("echo "test at noon" |mail) and again, I get two e-mails.
Anyone else have this problem?
Anyone know how to stop this?
When I started crond, I just did "sudo /etc/init.d/cron start"
Thanks,
- Ambrose
-
Ah ha!
I didn't think to check to see if two cron's were running, and that was it.
FYI, and 00:05 I get the e-mail with the time, and at 00:00 it sync's ![Wink](images/smilies/icon_wink.gif)
- Ambrose
-
Senior Member
registered user
--Yes, I know; but what is the real value of getting a mail at 5 minutes after midnight regardless? Wouldn't you rather get a mail at midnight from the clock-sync script? That lets you know if it ran Ok or not.
--Like so:
' ntpdate parm && date|mail -s "Clock sync script" ' (only sends the mail if return code from ntpdate = 0.) If you *don't* get the mail you know something went wronf. (humor intentional on the sp.)
--With 2 cron entries, the 5-after mail will be sent whether or not the ntpdate has run successfully; with the method above, you will know if it ran Ok.
![Quote](images/misc/quote_icon.png)
Originally Posted by
Ambrose
Ah ha!
I didn't think to check to see if two cron's were running, and that was it.
FYI, and 00:05 I get the e-mail with the time, and at 00:00 it sync's
- Ambrose
Similar Threads
-
By edallica in forum Hardware & Booting
Replies: 2
Last Post: 05-30-2005, 04:22 AM
-
By ghetto_blaster in forum Hdd Install / Debian / Apt
Replies: 1
Last Post: 05-16-2005, 09:09 AM
-
By goudiemark in forum Hdd Install / Debian / Apt
Replies: 2
Last Post: 01-11-2005, 10:40 PM
-
Replies: 4
Last Post: 11-25-2003, 04:28 PM
-
By arkaine23 in forum Customising & Remastering
Replies: 1
Last Post: 07-08-2003, 08:10 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
![1U BareMetal pfsense opnsense Router Firewall DNS Server 6x 10GB Ethernet Ports picture](/store/img/g/fxsAAOSwZD5l6PSG/s-l225/1U-BareMetal-pfsense-opnsense-Router-Firewall-DNS-.jpg)
1U BareMetal pfsense opnsense Router Firewall DNS Server 6x 10GB Ethernet Ports
$149.00
![1U 10 SFF Bay Supermicro Server X10DRW-iT 2x Xeon E5-2690 V4 128GB DDR4 RAM picture](/store/img/g/IxIAAOSwL5NjRJXz/s-l225/1U-10-SFF-Bay-Supermicro-Server-X10DRW-iT-2x-Xeon-.jpg)
1U 10 SFF Bay Supermicro Server X10DRW-iT 2x Xeon E5-2690 V4 128GB DDR4 RAM
$399.00
![VPS Windows / Linux Server - 12GB RAM, 4 Core, 1 TB HD, Unltd. bandwidth 1 Year picture](/store/img/g/BvgAAOSwxVReHqHl/s-l225/VPS-Windows-Linux-Server-12GB-RAM-4-Core-1-TB-HD-U.jpg)
VPS Windows / Linux Server - 12GB RAM, 4 Core, 1 TB HD, Unltd. bandwidth 1 Year
$282.95
![Dell PowerEdge R210 II Rackmount Server Xeon E31220L 16Gb 1TB + 500GB LINUX 6.6 picture](/store/img/g/v-EAAOSwjuZmMTyR/s-l225/Dell-PowerEdge-R210-II-Rackmount-Server-Xeon-E3122.jpg)
Dell PowerEdge R210 II Rackmount Server Xeon E31220L 16Gb 1TB + 500GB LINUX 6.6
$129.00
![SUSE LINUX Enterprise Server 9 Operating System Software New Sealed In Box picture](/store/img/g/dJ0AAOSwHMxmV3bq/s-l225/SUSE-LINUX-Enterprise-Server-9-Operating-System-So.jpg)
SUSE LINUX Enterprise Server 9 Operating System Software New Sealed In Box
$40.00
![Custom Server 15](/store/img/g/uCMAAOSw3xhj3a06/s-l225/Custom-Server-15-Depth-X11SSH-F-E3-1270-V6-3-8Ghz-.jpg)
Custom Server 15" Depth X11SSH-F E3-1270 V6 3.8Ghz 4 Core - 128GB NVME 32GB RAM
$399.00
![Globalscale Technologies DreamPlug AppNeta M22 Linux Server Dual GB Ethernet picture](/store/img/g/Xs4AAOSwjrlkdWYQ/s-l225/Globalscale-Technologies-DreamPlug-AppNeta-M22-Lin.jpg)
Globalscale Technologies DreamPlug AppNeta M22 Linux Server Dual GB Ethernet
$24.99
![Netapp DS2246 / DS4243 / DS4246 QSFP SFF-8436 Linux Server PCIe Quad PT SAS Card picture](/store/img/g/bCUAAOSwKxlddp~8/s-l225/Netapp-DS2246-DS4243-DS4246-QSFP-SFF-8436-Linux-Se.jpg)
Netapp DS2246 / DS4243 / DS4246 QSFP SFF-8436 Linux Server PCIe Quad PT SAS Card
$39.00
![SQL Server 2019 Standard (10 CAL) - Windows and Linux, Physical License picture](/store/img/g/ArsAAOSwK8hmckYN/s-l225/SQL-Server-2019-Standard-10-CAL-Windows-and-Linux-.jpg)
SQL Server 2019 Standard (10 CAL) - Windows and Linux, Physical License
$249.00
![Australia - Win/Linux Server- 2GB RAM, 1 Core,100 GB HD, Ultd Bandwidth 2 yrs picture](/store/img/g/BvgAAOSwxVReHqHl/s-l225/Australia-Win-Linux-Server-2GB-RAM-1-Core-100-GB-H.jpg)
Australia - Win/Linux Server- 2GB RAM, 1 Core,100 GB HD, Ultd Bandwidth 2 yrs
$202.11