Results 1 to 6 of 6

Thread: How to set CRON job to force reboot at a specified time?

  1. #1

    Question How to set CRON job to force reboot at a specified time?

    Cron job is not working at all. I have altered the time numerous times, waited for clock to catch up, and job has not executed.

    Here's what I have now:

    Code:
    linux:/etc/cron.d # l
    total 24
    drwxr-xr-x   2 root root  4096 Nov 19 19:12 ./
    drwxr-xr-x 173 root root 12288 Nov 19 17:27 ../
    -rw-r--r--   1 root root   542 Oct 11 13:30 mdadm
    -rw-r--r--   1 root root    49 Nov 19 18:50 zz-reboot
    
    linux:/etc/cron.d # cat zz-reboot 
    52 18 * * * root  /home/gost/MY_CRON_JOBS/reboot
    
    linux:/home/gost/MY_CRON_JOBS # l
    total 12
    drwxr-xr-x   2 gost users 4096 Nov 19 18:10 ./
    drwxr-xr-x 127 gost users 4096 Nov 19 18:20 ../
    -rw-r-xr-x   1 root root    20 Nov 19 18:10 reboot*
    
    linux:/home/gost/MY_CRON_JOBS # cat reboot 
    #!/bin/bash
    reboot
    I want to force a reboot at the specified time.

  2. #2

    Default [SOLVED] Re: How to set CRON job to force reboot at a specified time?

    I discovered the problem.

    The cron system requires a newline at the end of EVERY line in the crontab file.

    This means that when editing a crontab, one must press ENTER at the end of the command. Cron will not process a file missing this required newline.

  3. #3

    Default Re: How to set CRON job to force reboot at a specified time?

    However, it still will not run from /etc/cron.d. No crontab placed there runs.

    When I add it via crontab -e for the user, the cron job runs.

    I cannot figure this issue out.

  4. #4
    Join Date
    Oct 2008
    Location
    Glasgow, Scotland
    Posts
    1,134

    Default Re: How to set CRON job to force reboot at a specified time?

    Why not edit /etc/cron.d/zz-reboot to:

    Code:
    52 18 * * * root systemctl reboot
    ?
    ~Thank you for sharing an interesting problem.
    --
    slàinte mhath,
    rayH

  5. #5
    Join Date
    Mar 2008
    Location
    Oz
    Posts
    11,727
    Blog Entries
    2

    Default Re: How to set CRON job to force reboot at a specified time?

    Quote Originally Posted by ruckt View Post
    However, it still will not run from /etc/cron.d. No crontab placed there runs.

    When I add it via crontab -e for the user, the cron job runs.

    I cannot figure this issue out.
    I think cron is designed to respond only to cron -e. It's a security measure. Read the "man crontab". Clues in there.
    Leap 42.3 & 15.1(Beta) &KDE
    FYIs from the days of yore

  6. #6
    Join Date
    Oct 2008
    Location
    Glasgow, Scotland
    Posts
    1,134

    Default Re: How to set CRON job to force reboot at a specified time?

    Quote Originally Posted by swerdna View Post
    I think cron is designed to respond only to cron -e. It's a security measure. Read the "man crontab". Clues in there.
    There is no "cron -e" check "man cron" , which also explains the use of "/etc/cron.d/" etc. "crontab -e" is for normal users to edit their own crontab files in "/var/spool/cron/tabs/". The files in "/etc/cron.d/", "/etc/cron.daily/", "/etc/cron.weekly" and "/etc/cron.monthly" can be edited without a special tool by administrators and can run as any user.
    ~Thank you for sharing an interesting problem.
    --
    slàinte mhath,
    rayH

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •