Stop and start a process every X hours


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Stop and start a process every X hours
# 1  
Old 10-08-2013
Stop and start a process every X hours

Hi, I have a parallelized Mathematica program that spans across 8 MathKernels processes running at 100% and one MathKernel (highlighted in blue) running at < 10% that controls the other 8. They look like this on the cluster:

Stop and start a process every X hours-untitledjpg

I want to run these process indefinitely, but after a while, because of a Mathematica bug, the program continues to run at 100%, but stop giving me results.

One way to solve that is to kill the the controller MathKernel process (automatically the other 8 process are killed) and start again.

I would like a help on how to make a script that runs a command "C" and then after some time "X" kills the process belonging to me (giovform) called "MathKernel" running at < 10% cpu and then runs "C" again, all this in a loop. Is this possible? Sorry for asking too much.. Smilie

I am using nohup to execute my commands so I can close the terminal window without killing them.

Giovanni
Stop and start a process every X hours-untitledjpg
# 2  
Old 10-08-2013
The unsophisticated/brute force (run with nohup)

Code:
ex: 0602-132 The specified buffer is empty.
SLEEP_IN_SECS=900  #this is 15 minutes
while (( 1 ))
do
        ps -aef | grep MathKernel | awk '{print $1}' | while read a
        do
        kill ${a}
        done
sleep ${SLEEP_IN_SECS}
done

OR

or in cron (every 15 minutes)
Code:
0,15,30,45  *  * * * foo.sh


Code:
#foo.sh
 ps -aef | grep MathKernel | awk '{print $1}' | while read a
        do
        kill ${a}
        done

# 3  
Old 10-09-2013
Thanks!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

factor [start[stop]

Another question for you guys! This is so fun. So I am playing around with the factor operation. I read in "man factor" that you can actually print a list of primes in between a range, using the syntax factor ] However, every time I enter two values, it just returns the factored value.... (1 Reply)
Discussion started by: statichazard
1 Replies

2. UNIX for Dummies Questions & Answers

Stop/Start vs. Restart

Is there any functional difference between: issuing separate stop/start commands like this; super (handler) (instance) stop super (handler) (instance) start versus issuing a single recycle command like this; super (handler) (instance) restart (3 Replies)
Discussion started by: Newbix
3 Replies

3. Shell Programming and Scripting

Start/Stop process when a file is modified.

I have a file which is modified via a web application & this may happen during any time of the day/week. This file is being used a config/list file for another shell script which runs 24hrs with a sleep of 200 secs. I have writted a small script to kill the shell script when this config file is... (4 Replies)
Discussion started by: Lancel0t
4 Replies

4. Solaris

How to start/stop processes

Please anyone tell me In my last interview the HR asks me how to monitor, start,stop & kill the various processes and subprocesses. Please anyone explain me clearly. It's my personal request (3 Replies)
Discussion started by: suneelieg
3 Replies

5. Shell Programming and Scripting

Servers Start and Stop

HI I am using below code to start and stop servers but it is not working ,how to run the script please suggest me ,if any errors in the script please let me know. #!/bin/bash IMS_START="/Webserver/AppServer/bin/startServer.sh" IMS_STOP="/Webserver/AppServer/bin/stopServer.sh" case "$1" in ... (1 Reply)
Discussion started by: RG18173
1 Replies

6. Shell Programming and Scripting

Servers Stop and Start

Hi, Every time i want to stop and start servers using PuTTY,i have to execute 6 to 10 commands every time ,i need shell script(program) for execute those commands in single command.Is it possible plz suggest me. (3 Replies)
Discussion started by: RG18173
3 Replies

7. HP-UX

ypbind start/stop

Hi, How to start or stop ypbind on HP-UX machine. Searched a little but could not find. thanks, (2 Replies)
Discussion started by: jredx
2 Replies

8. Solaris

stop a process to start at system startup

Hi all! I'm running Solaris 10 and have a question about how i can stop a certain program to start at system startup,for example, as it is now sendmail is starting but i don't need sendmail,on the other hand so would i be very glad to get cups up and running at startup, anyone who can explain where... (3 Replies)
Discussion started by: larsgk
3 Replies

9. UNIX for Advanced & Expert Users

my process is going to sleep mode after 12 hours but i need my process in in firsy pr

hi all I process is sleeping after 12 hours but i need to be run this to 24 hours but it goes in sleep mode after 12 hours what should i do to make process always running.Kindly give me suggestion. (0 Replies)
Discussion started by: mukesh_rakesh1
0 Replies

10. AIX

Start Stop Apache

I am in the process of reorging my Lawson db. I need to turn off the RMI server...not a problem. However my instructions also state that I must also shutdown my Servlet Container....I believe it is Apache. I have looked in /usr/apache/bin/apachectl What is the command for stopping and... (2 Replies)
Discussion started by: MILLERJ62
2 Replies
Login or Register to Ask a Question