How to turn off the system automatically ?

Taking care of your Linux box.
Post Reply
gardenair
Havaldaar
Posts: 106
Joined: Tue Dec 28, 2004 10:07 pm

How to turn off the system automatically ?

Post by gardenair »

Hi,
I am using Cent Os 5. I want that the system should shutdown automatically at 7:00 pm daily and next day I manually turn on the system.I have google it but the syntax is not clear.

I use
# crontab -e
and write the command
0 19 * * * /sbin/shutdown -h now

I does't apply the command but please guide me that what is * * * after 19
Kindly guide me how can I enable this feature? and If i want to shutdown the system at 7:30 PM then how will it write ?
thanks in advance,
garden
Kamran.Ahmed
Lance Naik
Posts: 45
Joined: Wed Dec 16, 2009 5:57 pm
Location: Karachi

Post by Kamran.Ahmed »

use cron scheduler

type at shell crontab -e it will open vi editor then type below command

0 19 * * * /sbin/shutdown -h now

this cron command shutdown system at 7:00 pm daily
Kamran Ahmed Khan
kamran.cisco@gmail.com
Registered Linux User # 526139
www.allaboutlinux.org
gardenair
Havaldaar
Posts: 106
Joined: Tue Dec 28, 2004 10:07 pm

Post by gardenair »

thanks kamran bhai for the reply. Well what does * * * means ?
If I want to change the time 7:00 pm to 7:30 pm then it will be as

0 19 30 00 /sbin/shutdown -h now
Kamran.Ahmed
Lance Naik
Posts: 45
Joined: Wed Dec 16, 2009 5:57 pm
Location: Karachi

Post by Kamran.Ahmed »

in case you want to shutdown at 7:30 then command will be

0 19:30 * * * /sbin/shutdown -h now

i suggest kindly read man pages of the following

crond, crontab

man crond
man crontab

for more information and syntax
Kamran Ahmed Khan
kamran.cisco@gmail.com
Registered Linux User # 526139
www.allaboutlinux.org
gardenair
Havaldaar
Posts: 106
Joined: Tue Dec 28, 2004 10:07 pm

Post by gardenair »

thanks a lot for the reply.Actually In my Linux box squid is already running so before shutting down the system how can I stop squid service and then the system may shutdown with the crontab ?
Is this method will also stop squid service as well ?
thanks again for your valuable guidance,
garden
Kamran.Ahmed
Lance Naik
Posts: 45
Joined: Wed Dec 16, 2009 5:57 pm
Location: Karachi

Post by Kamran.Ahmed »

Dear you seems to me new to linux

shutdown command is full flagged command it is stopped all running services (deamons) properly then shutdown the system there is no need to stop squid etc if you apply without cron then issue

shutdown now

and if u stop squid manually

service squid stop
Kamran Ahmed Khan
kamran.cisco@gmail.com
Registered Linux User # 526139
www.allaboutlinux.org
gardenair
Havaldaar
Posts: 106
Joined: Tue Dec 28, 2004 10:07 pm

Post by gardenair »

thanks again for the reply. well I am not an expert in Linux but i am working on it each day.I have configured squid in my office and it is functional. Each day I discover new thing and it is helping me a lot for improving my linux in Linux.
Well I have also studies the man pages and it is wonderfull and have lot of things inside it. Well I have also tried with
0 14:30 * * * /sbin/shutdown -h now
but unfortunately it does not shutdown the system. Any idea thing missing I think
Kamran.Ahmed
Lance Naik
Posts: 45
Joined: Wed Dec 16, 2009 5:57 pm
Location: Karachi

Post by Kamran.Ahmed »

it will working as a cron job and i must be as below

30 14 * * * /sbin/shutdown -h now

study RHCE guide by Michele Jang it is awesome
Last edited by Kamran.Ahmed on Mon Mar 14, 2011 3:11 pm, edited 1 time in total.
Kamran Ahmed Khan
kamran.cisco@gmail.com
Registered Linux User # 526139
www.allaboutlinux.org
Kamran.Ahmed
Lance Naik
Posts: 45
Joined: Wed Dec 16, 2009 5:57 pm
Location: Karachi

Post by Kamran.Ahmed »

ohh i am sorry if you want to shutdown at 14:30 then command will be


30 14 * * * /sbin/shutdown -h now

kindly look into the syntax

# m h dom mon dow command
Kamran Ahmed Khan
kamran.cisco@gmail.com
Registered Linux User # 526139
www.allaboutlinux.org
gardenair
Havaldaar
Posts: 106
Joined: Tue Dec 28, 2004 10:07 pm

Post by gardenair »

thanks a lot Kamran bhai for your kind help and giving time for helping me. kindly check pm.
Post Reply