LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 03-12-2004, 06:59 PM   #1
alimharji
Member
 
Registered: Jan 2004
Posts: 35

Rep: Reputation: 15
simple code *help a newbie out*


aalright i need to write a small piece of code that runs in the form of a script. It can run standalone or be part of rc.d. The command that I need it to run aproximately every 5 minutes is "service ss5 start". Even better would be to run "service ss5 status" and if it is not running then run the command "service ss5 start".

The reason I need to do this is because I am running a socks server which randomly shuts off 1 a day or more. I emailed the author but he has no idea what is wrong. There are also no other servers that support socks that I could get working.

Any help is appreciated.

Alim

Last edited by alimharji; 03-12-2004 at 07:21 PM.
 
Old 03-12-2004, 07:45 PM   #2
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
Add:

5 * * * * service ss5 status | grep 'not running' &> /dev/null || service ss5 start

to root's crontab by running:

crontab -e

as root. crontab -e starts vi so hopefully you have the vi basics down.

Change "not running" to something that service ss5 status outputs if the service isn't running.

Lyle
 
Old 03-12-2004, 10:38 PM   #3
alimharji
Member
 
Registered: Jan 2004
Posts: 35

Original Poster
Rep: Reputation: 15
ok first after i type crontab -e i get the message no crontab for root - using empty one
then it opens a blank one and i add the lines you said above. I save it and when i try to exit it I get the message
crontab: installing new crontab
"/tmp/crontab.13980":1: bad day-of-month
errors in crontab file, can't install.
Do you want to retry the same edit?

now did i do something wrong? i did exactly as u said. COuld you please help?

Thanks
Alim
 
Old 03-13-2004, 02:52 AM   #4
AMMullan
Member
 
Registered: Sep 2003
Location: United Kingdom
Distribution: Ubuntu, Arch
Posts: 438

Rep: Reputation: 30
Can you post the crontab entry you used?
 
Old 03-13-2004, 07:15 AM   #5
alimharji
Member
 
Registered: Jan 2004
Posts: 35

Original Poster
Rep: Reputation: 15
i used the exact same one that Lyle_s suggested:

5 * * * * service ss5 status | grep 'not running'
&> /dev/null || service ss5 start
 
Old 03-13-2004, 07:24 AM   #6
alimharji
Member
 
Registered: Jan 2004
Posts: 35

Original Poster
Rep: Reputation: 15
i figured out you can do cron jobs in web min
now what i need to know is which part of the command should i put under 'command' and which should i put under 'input command'

thanks
 
Old 03-13-2004, 11:35 AM   #7
lyle_s
Member
 
Registered: Jul 2003
Distribution: Slackware
Posts: 392

Rep: Reputation: 55
Quote:
Originally posted by alimharji
lines
The command I gave you needs to be all on one line. Try again using crontab -e. I have no idea how to use webmin.

Remember to change "not running" to something that:

service ss5 status

outputs if the service isn't running.

Lyle
 
Old 03-14-2004, 01:23 PM   #8
alimharji
Member
 
Registered: Jan 2004
Posts: 35

Original Poster
Rep: Reputation: 15
alright i got it to work
thanks for the help
Alim
 
  


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
Simple PHP code aznita Programming 1 06-19-2005 11:50 PM
Interpret this simple C code Chase_G Programming 4 04-29-2005 09:07 AM
Whats wrong with this simple code Boffy Programming 6 10-31-2004 01:16 PM
error in compiling simple code Tinku Programming 6 09-17-2004 01:38 AM
to become giddy in simple code Hamid Moradmand Programming 2 05-18-2004 06:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:27 PM.

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
Open Source Consulting | Domain Registration