Register
It is currently Mon Dec 22, 2014 3:31 am

script to start proccess


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Wed Mar 11, 2009 8:27 pm   

Joined: Tue Dec 11, 2007 10:21 pm
Posts: 20
hello , does anyone have any ideea for a script do this:

to verify if proccess example is running if not then to start it like

ps aux search for example this does not exist starting it /bin/example or etc....

any ideea?


Top
 Profile  
 PostPosted: Thu Mar 12, 2009 5:00 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
There's a nice variety of init scripts on any linux in /etc/init.d/ or similar. Look for one that's close to what you want.

Also inittab can be used for services that need to run all the time and will restart a process whenever it dies.


Top
 Profile  
 PostPosted: Tue Mar 24, 2009 3:04 pm   

Joined: Tue Dec 11, 2007 10:21 pm
Posts: 20
DarthWavy wrote:
There's a nice variety of init scripts on any linux in /etc/init.d/ or similar. Look for one that's close to what you want.

Also inittab can be used for services that need to run all the time and will restart a process whenever it dies.


i need something to run into user with non full access , so he run a custom ./server proccess and i whant to make a script to start ./server when this crash or server gets reboot , , but i have no ideea from where to start.


Top
 Profile  
 PostPosted: Wed Apr 01, 2009 7:45 am   

Joined: Tue Mar 31, 2009 3:10 pm
Posts: 7
By pid
ps -p 5486 &> /dev/null
echo $?

By process name:
ps -C firefox-bin &> /dev/null
echo $?
if result is 0 the process is running, if the result is 1 it's not.

OR

if ! ps -p 12345 &> /dev/null; then
echo "Process not running"
else
echo "Process running"
fi

if ! ps -C firefox-bin &> /dev/null; then
firefox-bin
echo "firefox not running, started"
else
echo "firefox already running"
fi

Maybe have a look at the tracksessions function in the wireshark script in the sandbox, it keeps track of all the running sessions and acts when one dies


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP