• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Simple Linux help plz

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

Ba!nesy

Member
Joined
May 9, 2010
My bro needs a simple 'restart' script in "red hat linux".

Background info:

Using a WesternDigital (avoid) NAS, running red hat, and it has a program on it "mini_httpd" which is responsible for the web interface which is used to configure/setup the drive.

mini_httpd for whatever reason, crashes every few days.

He wants a script which will close mini_httpd (kill process perhaps?) and re-open it on VERY BASIC schedule (ie. 3:00AM - kill mini_httpd / 3:15AM -execute mini_httpd)

At this stage he's a linux NOOB tho - well versed with DOS / computers in general, but not the linux syntax/language.

Anyone able to post up a simple script/how to run it would be greatly appreciated!
 
You could create a bash script like this:
Code:
#!/bin/bash

/etc/init.d/mini_httpd restart

make it executable by doing chmod 777 /path/to/script

Then add the following line to /etc/crontab
Code:
0 3 * * * <absolute path to bash script>

Restart the cron daemon
Code:
/etc/init.d/crond restart

This will run it every day at 3am.
 
Last edited:
GREAT! I got all of that, makes sense, didn't know about crontab though - so thanks ebug! ;-)

One last question, to put that line in crontab do I:

cd /etc/crontab
vi crontab??

Once I'm in vi I can manage editing /saving etc, just how to get to that point?
 
vi /etc/crontab and it'll open up the file for you :)

I'm not 100% sure but I think you have to be root to edit it.

to edit cron jobs that run as root, yes. the correct way to do it is with the crontab command though. "man crontab" should tell you what you need to know
 
vi /etc/crontab and it'll open up the file for you :)

I'm not 100% sure but I think you have to be root to edit it.

Generally you would just run:

Code:
crontab -e

As any user and you will be editing that users crontab.

Code:
crontab -l

This will list what the current user has in his crontab.

You only need (or should) to be root if you want to do an operation that requires it.
 
lol :) yes... after a few days studying it turns out I meant a bash script ;-)
Equivalent of a batch file. I spose what I was asking for was the equivalent of a "windows script", lol. But thanks to everyone for clarifying!

;-)
 
Back