Solved shutdown by cron

Hi forum
One of my FreeBSD hosts is used as a simple daily desktop. No server tasks included.
To save some electrons, I like to shutdown each evening.
Unless I shutdown manually, I have a cron job to take care of it at 10.05 pm :
Code:
5       22      *       *       *       root    /sbin/poweroff

I don't mind that poweroff happens immediately, and shutdown can give warning/s.
Also, I don't much care for the unwanted emails sent by this cron job.
Should I simply append the usual "> /dev/null" to the cron job ?
Is this the-right-way to dispense with the emails from cron ?
TIA's
 
[…] Is this the-right-way to dispense with the emails from cron ? […]
The “right” way is documented in crontab(5): 📚
The sixth field […] specifies the command to be run. One or more command options may precede the command to modify processing behavior. […]​
‑nNo mail is sent after a successful run. The execution output will only be mailed if the command exits with a non‑zero exit code. […]
So this shall do: 🛌
Bash:
5       22      *       *       *       root    -n /sbin/poweroff
Note, the ‑n is an extension you may not find in other cron(8) implementations.
 
How about this alternative: In cron set the command to: "shutdown -p +5" (which brings the system down in 5 minutes, and gives users 5 minutes of warning). Then run the command at 10:00pm instead of 10:05, which preserve the same shutdown time.

Advantages? Users get a warning. Super user can cancel shutdown if desired. Otherwise, it makes little difference.
 
Back
Top