Discussion of programming on Linux, including shell scripting, perl, python, c/c++, mono, java. Whatever tickles your fancy.
gardenair
Havaldaar
Posts: 106 Joined: Tue Dec 28, 2004 10:07 pm
Post
by gardenair » Fri Oct 10, 2008 10:19 am
I want to shoult down or restart my system at 4 am .Please write the script that should do the specified task.
thanks in advance for the help.
gardenair
lambda
Major General
Posts: 3452 Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:
Post
by lambda » Fri Oct 10, 2008 11:15 am
type
if you want to execute multiple commands, put the commands in a file, one per line, and then type
read the man page for at.
Watch out for the
Manners Taliban !
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
x2oxen
Major General
Posts: 1114 Joined: Wed Aug 22, 2007 3:17 pm
Location: Faisalabad
Contact:
Post
by x2oxen » Fri Oct 10, 2008 5:24 pm
If you want to do it on daily basis you can add a cron job with shutdown command
gardenair
Havaldaar
Posts: 106 Joined: Tue Dec 28, 2004 10:07 pm
Post
by gardenair » Sun Oct 12, 2008 2:31 pm
well what should be the complete script ? and after writing the script in a text editor should i place in /etc folder ? guide me.
eternal peace
Naik
Posts: 86 Joined: Thu Apr 03, 2003 6:44 pm
Post
by eternal peace » Mon Oct 13, 2008 5:43 pm
There's no need to write a script for that as posted earlier you can do that using crontab only, here's how,
To add the cron job, do,
crontab -e
then, add,
0 4 * * * reboot
or
0 4 * * * poweroff
(to reboot or shutdown system at 4:00 a.m)
save changes and exit.
hail to linux!!!
gardenair
Havaldaar
Posts: 106 Joined: Tue Dec 28, 2004 10:07 pm
Post
by gardenair » Wed Oct 15, 2008 1:33 pm
chmod +x /etc/cron.daily/sysshutdown
what about it? your suggestions?
x2oxen
Major General
Posts: 1114 Joined: Wed Aug 22, 2007 3:17 pm
Location: Faisalabad
Contact:
Post
by x2oxen » Wed Oct 15, 2008 9:06 pm
no need to do that.. Just add a cronjob as advised earlier
lambda
Major General
Posts: 3452 Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:
Post
by lambda » Thu Oct 16, 2008 11:46 am
all cron.daily scripts (on my system) run at 6:25am (see your /etc/crontab for details). you could change the time in /etc/crontab, but then some of the scripts in /etc/cron.daily will run, and the rest won't because your shutdown script ran first.
Watch out for the
Manners Taliban !
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?
nomankhn
Colonel
Posts: 714 Joined: Wed Aug 07, 2002 8:00 pm
Post
by nomankhn » Fri Oct 31, 2008 6:04 am
I think he is asking home work step by step.?
Thanks,
Noman Liaquat
x2oxen
Major General
Posts: 1114 Joined: Wed Aug 22, 2007 3:17 pm
Location: Faisalabad
Contact:
Post
by x2oxen » Fri Oct 31, 2008 9:44 am
Noman that was 15 days ago.. Come move on to new posts
nomankhn
Colonel
Posts: 714 Joined: Wed Aug 07, 2002 8:00 pm
Post
by nomankhn » Sat Nov 01, 2008 4:57 am
x2oxen wrote: Noman that was 15 days ago.. Come move on to new posts
i got yesterday na
Thanks,
Noman Liaquat