Results 1 to 4 of 4

Thread: crontab time issues

  1. #1
    Member registered user
    Join Date
    Feb 2003
    Location
    Vancouver BC
    Posts
    92

    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

  2. #2
    Senior Member registered user
    Join Date
    Nov 2002
    Location
    USA, IL
    Posts
    1,041

    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 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

  3. #3
    Member registered user
    Join Date
    Feb 2003
    Location
    Vancouver BC
    Posts
    92
    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

  4. #4
    Senior Member registered user
    Join Date
    Nov 2002
    Location
    USA, IL
    Posts
    1,041
    --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 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

  1. first time
    By edallica in forum Hardware & Booting
    Replies: 2
    Last Post: 05-30-2005, 04:22 AM
  2. Crontab won't start automatically in the startup
    By ghetto_blaster in forum Hdd Install / Debian / Apt
    Replies: 1
    Last Post: 05-16-2005, 09:09 AM
  3. Crontab Not Working on 3.6
    By goudiemark in forum Hdd Install / Debian / Apt
    Replies: 2
    Last Post: 01-11-2005, 10:40 PM
  4. TV time !
    By mihai in forum Ideas
    Replies: 4
    Last Post: 11-25-2003, 04:28 PM
  5. Trying to make a root crontab, not working....
    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
  •  


Kingston 32GB 64GB 128GB 256GB USB 3.0 Flash Drive Thumb Memory Stick Pen lot picture

Kingston 32GB 64GB 128GB 256GB USB 3.0 Flash Drive Thumb Memory Stick Pen lot

$285.90



Microsoft Windows 11 Pro 64bit - New Sealed – Flash USB 1 PC picture

Microsoft Windows 11 Pro 64bit - New Sealed – Flash USB 1 PC

$49.99



Zero Trace Pen: All-in-one Tor Network Anonymous Drive + Cryptocurrency Wallet picture

Zero Trace Pen: All-in-one Tor Network Anonymous Drive + Cryptocurrency Wallet

$147.00



Wholesale Sale 10/ 30/ 50/100pcs 256MB Metal Swivel USB Flash Drive Memory Stick picture

Wholesale Sale 10/ 30/ 50/100pcs 256MB Metal Swivel USB Flash Drive Memory Stick

$165.90



Lot 5/10pcs USB Flash Drive Memory Stick 1MB-64GB Pendrive Thumb Drive 8GB 32GB picture

Lot 5/10pcs USB Flash Drive Memory Stick 1MB-64GB Pendrive Thumb Drive 8GB 32GB

$236.00



USB Type-A Flash Drive Metal Memory Stick High Speed USB Drive 128GB 256GB 512GB picture

USB Type-A Flash Drive Metal Memory Stick High Speed USB Drive 128GB 256GB 512GB

$8.47



LOT 10x SanDisk 32GB ULTRA USB 3.0 flash drive SDCZ48-032G 32 GB read 100 MB/s picture

LOT 10x SanDisk 32GB ULTRA USB 3.0 flash drive SDCZ48-032G 32 GB read 100 MB/s

$39.80



USB Type-A Flash Drive Metal Memory Stick High Speed USB Drive 128GB 256GB 512GB picture

USB Type-A Flash Drive Metal Memory Stick High Speed USB Drive 128GB 256GB 512GB

$7.99



TESLA OEM Model S,3,X,Y USB Flash Drive for Dashcam 128GB READ DESCRIPTION BELOW picture

TESLA OEM Model S,3,X,Y USB Flash Drive for Dashcam 128GB READ DESCRIPTION BELOW

$22.00



SanDisk Ultra Luxe USB 3.1 Flash Drive – 5 Pack | Premium Metal USB Flash Drives picture

SanDisk Ultra Luxe USB 3.1 Flash Drive – 5 Pack | Premium Metal USB Flash Drives

$49.99