Monday, July 26, 2010

Shutdown Linux Box Automatically Cent OS/RHEL/Fedora

Common Tasks For at Command

  1. Shutdown/reboot the system
  2. Email yourself files
  3. Send birthday remainders


  • at- Execute a task at a specific time. For example, shutdown computer, send birthday remainder etc. Useful to schedule one job at a time or a single future event.
  • cron – If you want to shutdown Linux box automatically everyday 8 pm then you need to use cron instead of at command (see below for examples). Useful to schedule recurring events or daily events such as backup data, or check system security etc.

at Command Examples

Let us see how to shutdow a Linux automatically at 8 pm, type the command at 8pm and press [enter] key, then type halt followed by enter key. To save your job press CTRL+D.

# at 8pm

Sample outputs:

at> halt
(Press CTRL+D)
Try out the following utilities:
  • atq - List the current at jobs pending.
  • atrm - Used to remove pending at jobs.
at command accept fairly complex time specifications, for example:
Run job at 6am on monday:

at 6am monday
Run job in 5 minutes time:
at now + 5 minutes
Run job at 4pm but 3 days later:
at 4pm + 3 days
Run job at 10am on 31st July:
at 10am Jul 31
See the file /usr/share/doc/at/timespec for complete time specifications
and read man pages of at, atq, atrm. Make sure you have atd service 
running, if not start it using the following command: 

# /etc/init.d/atd start

Linux Cron job to Shutdown Linux server/Desktop system

First, login as the root user and at a shell prompt type crontab -e command so that you can add cronjob:

# crontab -e
# crontab -e -u root
Append the following entry to it to shutdown box at 20:00 hrs [24 hour close format]:
0 20 * * * /sbin/shutdown -h now
Save and close the file. 

Post a Comment