0

I'm trying to reboot my server with cron job. I added below line

35 14 * * * root shutdown -r now

But nothing happens. I shared journalctl log at below

>Feb 15 14:35:01 example CRON[2840]: pam_unix(cron:session): session opened for user root by (uid=0)
>Feb 15 14:35:01 example CRON[2848]: (root) CMD (root /sbin/shutdown -r now)
>Feb 15 14:35:01 example CRON[2840]: pam_unix(cron:session): session closed for user root

Note: I tried both shutdown and /sbin/shutdown. But still same.

How do I fix this ?

Hasan Tıngır
  • 267
  • 4
  • 18

2 Answers2

1

You need to edit a cronjob of the root user.

  1. sudo -i

  2. crontab -e

  3. Edit cronjob as needed:

    35 14 * * * root shutdown -r now
    

Work!

Eliah Kagan
  • 117,780
Knn
  • 11
0

Go to the directory /etc/cron.d, Take a copy of one of the existing files and change the job to:

35 14 * * * root systemctl isolate reboot.target