LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-13-2003, 05:59 AM   #1
Virtus
Newbie
 
Registered: Jan 2003
Location: Denmark
Distribution: Redhat 8.0
Posts: 14

Rep: Reputation: 0
Cron Reboot


How do i add a simple cron job that makes my server reboot at 08am every sunday..

And if possible does anyone have a perl og shell script that makes the server reboot on varible times.. ie.
Server has a range from 8am to 10am where it can reboot on sundays..
One sunday it reboots at 8:19am
the next sun day at 9:35am and so on and so on..

Im not a programmer at all so i cant make such a script myself, if anyone has one or could code it for me i would appriciate it alot..

Thanks in advance

**Forgot to say its a Redhat 7.2 dist. runnings as DNS server**
 
Old 01-13-2003, 07:53 AM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530Reputation: 3530
* 08 * * 7 root <command>
Code:
#!/bin/sh
r_min="8"; r_max="9"
if [ "$(expr ${RANDOM} / 60 / 60)" -ge "5" ]; then
a="${r_min}"; else a="${r_max}"; fi
echo shutdown -r 0${a}:$(expr ${RANDOM} / 60 / 60)$(expr ${RANDOM} / 60 / 60)
If you run the script and are satisfied with the outcome, remove the "echo" from "echo shutdown" and place it in /etc/crontab as for example
* 08 * * 7 root </etc/cron.scripts/shut_rand.sh>

OTOH if it's about DNS server probs you better investigate those first.

Last edited by unSpawn; 01-13-2003 at 07:57 AM.
 
Old 01-13-2003, 08:09 AM   #3
Virtus
Newbie
 
Registered: Jan 2003
Location: Denmark
Distribution: Redhat 8.0
Posts: 14

Original Poster
Rep: Reputation: 0
Thanks a million, this is just what i needed...

The Dns Servers are running fine, no problems at all..
 
Old 01-13-2003, 08:42 AM   #4
Virtus
Newbie
 
Registered: Jan 2003
Location: Denmark
Distribution: Redhat 8.0
Posts: 14

Original Poster
Rep: Reputation: 0
unSpawn > How do i test if the script work ??
i did a
[root@ns2 cron.scripts]# ./shut_rand.sh
bash: ./shut_rand.sh: bad interpreter: Permission denied

Did not work.. =/
 
  


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
shell script using /etc/cron.hourly to execute cron.php file? rioguia Programming 3 06-11-2008 09:09 AM
cron reboot problem tcpdump Linux - Software 3 05-14-2004 07:05 AM
[cron][mdk9.1]cron deamon seems to ignore some task... yannrichet Linux - Newbie 5 06-26-2003 10:57 AM
dual entries in cron log for cron.daily cpharvey Linux - General 3 02-27-2003 03:30 PM
Using cron to start a program at reboot ? s&j Linux - General 2 06-22-2002 05:31 PM


All times are GMT -5. The time now is 08:58 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