LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-20-2015, 01:29 PM   #1
Pearl123
LQ Newbie
 
Registered: May 2013
Posts: 17

Rep: Reputation: Disabled
Script help to shutdown and start


Dear Friends,

I am new to scripting. I want a help on script to schedule the shutdown and start up . I am using SUSE Linux system. Can some one guide me please

every night shutdown at 7pm & start it at 7am the next day during the weekdays. On the weekends, the server only needs to restart at 7am on Mondays.

Looking forward for help

Thank you

Regards

pearl

Last edited by Pearl123; 04-20-2015 at 01:58 PM.
 
Old 04-20-2015, 01:53 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 15,722

Rep: Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751
You can use cron to schedule the times as desired and hopefully depending on the age of your computer, its ACPI is supported.

https://www.linux.com/learn/docs/672...c-alarm-clock/
 
Old 04-20-2015, 02:32 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,806

Rep: Reputation: 4179Reputation: 4179Reputation: 4179Reputation: 4179Reputation: 4179Reputation: 4179Reputation: 4179Reputation: 4179Reputation: 4179Reputation: 4179Reputation: 4179
Quote:
Originally Posted by Pearl123 View Post
Dear Friends,
I am new to scripting. I want a help on script to schedule the shutdown and start up . I am using SUSE Linux system. Can some one guide me please every night shutdown at 7pm & start it at 7am the next day during the weekdays. On the weekends, the server only needs to restart at 7am on Mondays.
We will be very happy to help you with a script. So, post what you have written/done so far, and tell us where you're stuck. Also, please read the "Question Guidelines" link in my posting signature. Providing details is something that helps others answer your question..."SUSE Linux" doesn't tell us much.

There are many easily-found examples about how to schedule cron jobs, such as the one michaelk pointed you to. Since you've been using Linux now for two years, you must have some basic knowledge by this point. If you're needing help getting started writing a script, check out the bash scripting tutorial in my posting signature, as well as any of the THOUSANDS you can find with a brief search.

post back with your script and specific questions, and we'll be happy to help.
 
Old 04-20-2015, 08:56 PM   #4
Pearl123
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
Hi

Thanks for your reply

Here is what I have tried in crontab

0 19 * * 1-5 /sbin/shutdown
0 07 * * 1-5 /sbin/reboot

One is to shutdown at 7 pm at night every day from Monday to Friday and start up at 7 am every day from Monday to Friday. Am I starting correct

SUSE Enterprise Linux 11 is the OS I am using. Please guide.
 
Old 04-20-2015, 09:39 PM   #5
michaelk
Moderator
 
Registered: Aug 2002
Posts: 15,722

Rep: Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751Reputation: 1751
No, the script in the link sets the wake time as well as shutdown so only one cron job is necessary. Have you tried running the wake up test to see if it works on your computer?

Last edited by michaelk; 04-20-2015 at 09:43 PM.
 
1 members found this post helpful.
Old 04-20-2015, 09:49 PM   #6
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,206

Rep: Reputation: 197Reputation: 197
Cool

Quote:
Originally Posted by Pearl123 View Post
Hi

Thanks for your reply

Here is what I have tried in crontab

0 19 * * 1-5 /sbin/shutdown
0 07 * * 1-5 /sbin/reboot

One is to shutdown at 7 pm at night every day from Monday to Friday and start up at 7 am every day from Monday to Friday. Am I starting correct

SUSE Enterprise Linux 11 is the OS I am using. Please guide.
I think your server will not wake up unless you have some device or software to do it, like WOL- Wake On Lan.

Check out this link to get some idea:
https://help.ubuntu.com/community/WakeOnLan
 
1 members found this post helpful.
Old 04-20-2015, 10:25 PM   #7
Pearl123
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
Hi ,

Sorry I did not get the point, meaning no need of two lines is it, or through command I cannot boot the server remotely.

Please help to know where I am going wrong and what I should be doing as I need to shutdown this night

Thanks
 
Old 04-20-2015, 10:50 PM   #8
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Quote:
Originally Posted by Pearl123 View Post
Hi ,

Sorry I did not get the point, meaning no need of two lines is it, or through command I cannot boot the server remotely.

Please help to know where I am going wrong and what I should be doing as I need to shutdown this night

Thanks
michaelk and JJJCR are right, do you have WOL (Wake on LAN) or DRAC or iLO configured on this server? There is no script which can power on the server because once it is down why would server care about the script?

If you don't have WOL or DRAC or iLO configured do not power off the server as you will not be able to power it back on. Only go with server shutdown once you have made sure that you are able to remotely power on the server.
 
Old 04-20-2015, 11:01 PM   #9
Pearl123
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
Hi T3RM1NVT0R

oh ok I don't have anything configured in my server. I was assuming that I could reboot the server having 7 hours apart. Sorry If I am on wrong path

Sorry michaelk and JJJCR for not getting the point initially

Regards
Pearl
 
Old 04-20-2015, 11:27 PM   #10
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
If you power down a system completely then would have to physically press the power button to start the system. So wake on lan and may be wake on rtc solves this problem by starting the system on a LAN(network) event. So try that first and then scripts to invoke reboot or shutdown.
 
Old 04-21-2015, 01:01 AM   #11
Pearl123
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
Hi All,

Thank you. Here is the proceedings which I have done after the suggestions advised by you all

I have completed the WOL set up in the yast for the server which I need to shutdown and boot up on a scheduled basis

Start YaST as root user and select Network Services+WOL. If there is a DHCP server running on your computer, the WOL module displays the existing computers on your network that you can include in your WOL list.

If a DHCP server is not running, enter the remote computers manually. Click Add and enter the host name and MAC (media access connector) address for the network card. The MAC address is unique for every network device and can be displayed with:
# ip link show eth0
2: eth0: <BROADCAST,MULTICAST,NOTRAILERS,UP>
mtu 1500 qdisc pfifo_fast qlen 1000
link/ether 00:80:c8:94:c3:e7 brd ff:ff:ff:ff:ff:ff


In Enter the MAC Address of the client:, enter the value contained in link/ether. Confirm with Save. The configuration with YaST is now complete
.

But now I don't know what next I can do to trigger this

Please guide

Thanks
Pearl
 
Old 04-21-2015, 01:32 AM   #12
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Have a look at this link: http://www-uxsup.csx.cam.ac.uk/pub/d...9/ch17s07.html

If you do not have any other way to power ON the computer remotely that is using iLO or DRAC then I would suggest to perform this WOL test only when someone is at DC. Incase WOL doesn't work then the person will be able to turn on the system so that you can configure it and test again.
 
Old 04-21-2015, 01:40 AM   #13
Pearl123
LQ Newbie
 
Registered: May 2013
Posts: 17

Original Poster
Rep: Reputation: Disabled
Hi T3RM1NVT0R

Yes I have completed that step. So now I need to schedule it meaning I shutdown down at 7pm Today Tomorrow I need to use that WAKE UP Automatically.

How should I proceed now in terms of scripting.

Thank you

Regards
Pearl
 
Old 04-21-2015, 02:00 AM   #14
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Quote:
Originally Posted by Pearl123 View Post
Hi T3RM1NVT0R

Yes I have completed that step. So now I need to schedule it meaning I shutdown down at 7pm Today Tomorrow I need to use that WAKE UP Automatically.

How should I proceed now in terms of scripting.

Thank you

Regards
Pearl
As it says in the document:

"17.7.3. Waking up Computers

If your computers are appropriately configured, wake them up in the WOL YaST module by clicking Wake up. The selected computer then starts.

Another option is to enter the command ether-wake from the netdiag package. With this command, a particular computer can be woken up by entering its MAC address as in ether-wake 00:80:C8:94:C3:E7. Obtain help for this command with --help or -u. "

Before jumping on with script you first need to test if computer is indeed waking up. As of now you did the configuration but you are not sure if it will wake up the system. As I mentioned in my previous post make sure that you have someone at DC to power on the system incase it doesn't wake up. Did you already check BIOS and made sure that Boot from LAN is enabled?

For the scripting part you can put this command: ether-wake 00:80:C8:94:C3:E7 (mac address will be of the machine you want to wake up) in a file say wake.sh and put it in cron to run at the time you want system to wake up. Again I will emphasize that make sure you have someone at the site to power on the system incase it doesn't come up via WOL.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shutdown script to gently close programs opened by a user at his start-up session jamesblue Linux - Newbie 5 04-08-2013 02:43 AM
Start-Up Script & Shutdown/Kill Script needed guggilamsandeep Red Hat 1 05-11-2011 08:58 AM
Question Shell script to shutdown virtual machines. copy, and than start VM simmouk87 Linux - General 3 03-20-2011 03:51 PM
remote start and shutdown upload-3 Linux - Networking 3 12-24-2004 05:20 AM
Start-Up/Shutdown Script ptreves Linux - Newbie 1 09-15-2004 04:27 PM


All times are GMT -5. The time now is 06:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration