Search code examples
linuxubuntucronlinux-mint

crontab shutdown command never runs


Well as far as I can tell, I'm doing everything I've been told.

The command "shutdown -P now" at the commandline does exactly what I want - immediately shut down the computer. But using that command as a cron job just never happens.

I just want it to shut down Monday through to Friday, at 8:30pm, and then again at 9:30pm and 10:30pm. So here's what I do;

I type "crontab -e", and I add this at the bottom of the file:

30 20,21,22 * * 1-5 shutdown -P now

I press CTRL+O to "save" it, and then CTRL+X to quit. I get the "crontab: installing new crontab" message at the prompt.

But come 8:30pm, no shutdown. Nor at 9:30p, or 10:30pm.


Edit: Working through the list provided here; CronJob not running

I'm stopped at "Test cron is working". I enter the command

* * * * * /bin/echo "cron works" >> /tmp/file

And I get the error

Apps: command not found

Searching for this error in Google doesn't turn up anything relevant.

Also, I was finally able to see (thanks to the link) where to get my message log output - I'm in Linux Mint (should have mentioned that), so I needed the Ubuntu way of finding the log output. The shutdown command appears to be run, and the only "error" message is "no MTA installed", which (from what I just read) is just for emailing the output. Otherwise there doesn't seem to be any obvious error message... can someone make any sense of this?

domarius@Domarius-LinuxMint ~ $ grep CRON /var/log/syslog
Aug  3 08:17:01 Domarius-LinuxMint CRON[3259]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  3 09:17:01 Domarius-LinuxMint CRON[3876]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  3 10:17:01 Domarius-LinuxMint CRON[4122]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  3 11:17:01 Domarius-LinuxMint CRON[4349]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  3 12:17:01 Domarius-LinuxMint CRON[4719]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  3 13:17:01 Domarius-LinuxMint CRON[5028]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  3 14:17:01 Domarius-LinuxMint CRON[5317]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  3 15:17:01 Domarius-LinuxMint CRON[5933]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  3 16:17:01 Domarius-LinuxMint CRON[7083]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  3 20:26:38 Domarius-LinuxMint cron[1089]: (CRON) INFO (pidfile fd = 3)
Aug  3 20:26:38 Domarius-LinuxMint cron[1089]: (CRON) INFO (Running @reboot jobs)
Aug  3 20:30:01 Domarius-LinuxMint CRON[2670]: (root) CMD (shutdown -P now "Shutting down...")
Aug  3 20:30:01 Domarius-LinuxMint CRON[2671]: (domarius) CMD (/sbin/shutdown -p now)
Aug  3 20:30:01 Domarius-LinuxMint CRON[2669]: (CRON) info (No MTA installed, discarding output)
Aug  3 20:30:01 Domarius-LinuxMint CRON[2668]: (CRON) info (No MTA installed, discarding output)
Aug  3 21:17:01 Domarius-LinuxMint CRON[3058]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Aug  3 21:30:01 Domarius-LinuxMint CRON[3232]: (domarius) CMD (/sbin/shutdown -p now)
Aug  3 21:30:01 Domarius-LinuxMint CRON[3233]: (root) CMD (shutdown -P now "Shutting down...")
Aug  3 21:30:01 Domarius-LinuxMint CRON[3231]: (CRON) info (No MTA installed, discarding output)
Aug  3 21:30:01 Domarius-LinuxMint CRON[3230]: (CRON) info (No MTA installed, discarding output)
Aug  3 22:17:01 Domarius-LinuxMint CRON[3515]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)

Solution

  • After my question was unhelpfully downvoted with a link to a lot of things that didn't work, I got the help I needed on the Linux Mint forums - the secret was to edit crontab using the sudo command; "sudo crontab -e" That and other useful info is at this post. https://forums.linuxmint.com/viewtopic.php?f=47&t=275029&p=1507982#p1507982