I need part of my script to be able to loop, check for processes running and if they aren't running, start them. It needs to loop 5 times, do a check each time, and make sure a process starts, and if its running; skip it.
I've worked with loops and checking for processes before, but this one has me stumped.
Last edited by jeffs42885; 12-16-2010 at 10:54 AM..
What OS, what shell? ---------- Post updated at 17:08 ---------- Previous update was at 16:50 ----------
Im missing something here: Are you changing 3 time of directory (if so wht is the point?), or is there something missing ( cd; or cd dir1; startprocess1.sh)?
Hi Jeff,
provide me the processes that should run every day and put it in a file say file 1
and find the current that would compare the current processes alive and put the output 2 file say file 2
use diff command to find those processes not running .
and restart those process .
also to check for loops ,
if you require you can create another script which wuld run the above script with while condition and that condition which will always gets satisfied. say
Last edited by Franklin52; 12-18-2010 at 10:54 AM..
Reason: Please indent your code and use code tags, thanks
You might have trouble with using ps & grep, because sometimes
will find a processes "grep something", so you can get spurious errors.
You would be safer using a regular expression in the grep, even if there is nothing to expand. Something like:-
will never match the grep statement itself. Apart from that, you code looks okay, but it could be simplified. If I may suggest:
Of course, if you logic is that if neither process is running, you would want an AND condition, so a -a flag in the if statement. Of course, if that is the case, you can save some processing by combining the first two lines, so:
I hope that this is useful, but if i have missed the point, please write back and hopefully I or someone else will correct it.
In several scripts that process files matched by name pattern I needed to add a check for file existence. Just to illustrate let's say I need to process all N??? files:
/tmp$ touch N100 N101
/tmp$ l ?10
-rw-rw-r-- 1 moss group 0 Apr 19 11:22 N100
-rw-rw-r-- 1 moss group ... (10 Replies)
Hi all,
q1) If i am in a global-zone, is there any command or anyway to check if a particular process in "ps -ef" output is running in which zone ?
q2) if i have created and mount a lofs filesystem/mountpoint for my non-global zone, can i say the following
e.g.
/dev/md/dsk/d60 /data --... (1 Reply)
I want to check processes on my Linux server
Normally we do a ps-ef|grep "search code"
Now we want to check for certain processes which are up and running and we want to get an email, whenever the processes we are checking goes down?
How can i implement this? (1 Reply)
Hi
I my shell scripting(Main.ksh) i am calling the another loader.ksh using nohup inside the for loop ...so the above command runs parallel. Loader.ksh generate the dummy file seq_n.run file and deleted in the end of the Loader.ksh
In the main.ksh .. after the for loop .. i have to check... (1 Reply)
Hi,
I want to create a script who will check if the java process is running & if it finds the process is still there it continues to execute & when the process completes it exit from the script.
I have written a code to check & notify the process existence but i am not getting how to write... (4 Replies)
Hi all,
I have one clarification i am using the loop which will process for each record .suppose there is f ailure in the first record it need to send mail and process the next .my code:
defcount=`cat <filename>|wc -l`
while ]
do
if <some condiotion>
then
echo "mail"
fi
done
so... (1 Reply)
Hi,
Am working on linux. while forking in a loop how to avoid the child process from forking..for example
int n = 5;
pid_t pid;
pid_t ch_pid;
/*exactly wanted to create n processes and not 2^n processes*/
for(i = 0; i < n;i++)
{
if(pid = fork())
{
/* parent... (4 Replies)
Hi,
I have 2 start and stop sh.
Start sh
--------
This will start few processes.
Example code:
echo "start process : lgz200 /pipe=test_jobs"
nohup lgz200 /db=test/test1@test1 /pipe=test_jobs > ../log/lgz200_j.log &
echo "echo \"stop process (pid=$!): lgz200 /pipe=test_jobs\"" >>... (3 Replies)
I have aix version 5.1
I was wondering how I can check all running processes?
I have used several ps commands but have been unsuccessful at it. I can see all with {ps aux } I have a little trouble knowing what I am looking for also. I should be looking at length of time and processor usage? I am... (3 Replies)
I'm trying to do the following:
1) Run a bunch of jobs in the background
2) Determine if any one of them returns with a non-zero exit status
Here's what I've come up with so far:
##########################################
#!/bin/ksh
while } -lt 1024 ]
do
SLEEP_TIME=`expr 1024 -... (2 Replies)