Sponsored Content
Top Forums Shell Programming and Scripting How to add conditional check of whether a process is running before doing rest of script? Post 302856231 by Corona688 on Monday 23rd of September 2013 11:57:03 AM
Old 09-23-2013
Quote:
Originally Posted by nbsparks
Hi everyone,

So the thread so far has left me confused. So I kept digging. If found some code and modified it to this:
Code:
if ps -u mcmaps | grep 'overviewer.py'
then
     echo Running
else
     echo Not Running
fi

So far, this works. The "overviewer.py" is only run from the mcmaps user. And when it is currently running, the script above reports "Running." When it's not running, it accurately states, "Not Running" (so far).

So, would this work? What are the dangers of this?
The dangers of not using a proper PID file are those of accidentally creating more than one instance by running one check shortly after another.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

script to check for a particular process and alert if its not running

Hai Friends, I have to develop a script that checks for a particular process say x.exe once every day and report if its not running say through a blat mail. I need this to run in a given list of pc from a single point. Any suggestion of how to go abt this Thnx for any help (1 Reply)
Discussion started by: goks
1 Replies

2. UNIX for Advanced & Expert Users

how to check if a process is running in a server from shell script.

I want to write a unix shell script that will check if a process (say debu) is running in the server or not. If no , then send a mail to the corresponding person to start the process??? (2 Replies)
Discussion started by: debu
2 Replies

3. Shell Programming and Scripting

script to check if process is running

How do I make a shell script to see if a certain process is running. The process shows up on ps aux as /usr/sbin/daemon eg: if /usr/sbin/daemon else #nothin basically i want to run the process if it isnt running/ has been stopped. Thanks. (2 Replies)
Discussion started by: daydreamer
2 Replies

4. Shell Programming and Scripting

How to write an expect script to check if a process is running?

I'm new to expecting and i want to create a script to ssh to a device,check is a process is running and display that the process is running or not.This is what i have so far After executing this script i get an error. #!/usr/bin/expect set timeout -1 set ip "machine ip goes here" set... (5 Replies)
Discussion started by: icchi
5 Replies

5. Programming

How do I check if a process is running in C

How to I check if a process is running in C? I'm trying to use ps aux |grep "process name" but failing in doing that. How do I do that? Thanks, (1 Reply)
Discussion started by: cprogdude
1 Replies

6. Shell Programming and Scripting

Script to check running of process

Hi, Can anyone please tell me how to write a shell script to check whether a process if running or not.... if its still running then wait for sometime and if not then run the next query. Also, Under my one main script main.sh I have to run 2 scripts simutaneously which take some time to... (2 Replies)
Discussion started by: lovepujain
2 Replies

7. Shell Programming and Scripting

Simple Script to Check running Process

#!/bin/sh CHECK='ps aux | grep start.jar | grep -v grep | wc -l' if then /usr/local/jre-1.7.0/bin/java - jar start.jar & else fi Could anybody advise whats up with this code im trying to put this in as a cron job to check that solr search engine is running every 10secs and if... (10 Replies)
Discussion started by: will_123
10 Replies

8. UNIX for Dummies Questions & Answers

How a process can check if a particular process is running on different machine?

I have process1 running on one machine and generating some log file. Now another process which can be launched on any machine wants to know if process1 is running or not and also in case it is running it wants to stream the logs file generated by process1 on terminal from which process2 is... (2 Replies)
Discussion started by: saurabhnsit2001
2 Replies

9. Shell Programming and Scripting

ksh script to check if certain process is running

I have to kill the process "test" for a maintenance I do but want the script to check when it comes back up. I can get what I want when I run this while loop: while true;do ps -ef | grep test | grep -v grep | sed -e 's/^*//';sleep 60;done but I want the script to do it for me and as soon as... (6 Replies)
Discussion started by: seekryts15
6 Replies

10. Web Development

Javascript to check field is empty then execute rest of script

I have found this bit of code that nearly does what I want. Basically 3 input fields, I want to copy t2 to t3 as it's typed but only if t1 contains data AND t3 is empty: <input type="text" id="t1" /> <input type="text" id="t2" /> <input type="text" id="t3" /> <script> var t2 =... (4 Replies)
Discussion started by: barrydocks
4 Replies
hackbench(8)															      hackbench(8)

NAME
hackbench - scheduler benchmark/stress test SYNOPSIS
hackbench [-p|--pipe] [-s|--datasize <bytes>] [-l|--loops <num-loops>] [-g|--groups <num-groups>] [-f|--fds <num-fds>] [-T|--threads] [-P|--process] [--help] DESCRIPTION
Hackbench is both a benchmark and a stress test for the Linux kernel scheduler. It's main job is to create a specified number of pairs of schedulable entities (either threads or traditional processes) which communicate via either sockets or pipes and time how long it takes for each pair to send data back and forth. OPTIONS
These programs follow the usual GNU command line syntax, with long options starting with two dashes ("--"). A summary of options is included below. -p, --pipe Sends the data via a pipe instead of the socket (default) -s, --datasize=<size in bytes> Sets the amount of data to send in each message -l, --loops=<number of loops> How many messages each sender/receiver pair should send -g, --groups=<number of groups> Defines how many groups of senders and receivers should be started -f, --fds=<number of file descriptors> Defines how many file descriptors each child should use. Note that the effective number will be twice the amount you set here, as the sender and receiver children will each open the given amount of file descriptors. -T, --threads Each sender/receiver child will be a POSIX thread of the parent. -P, --process Hackbench will use fork() on all children (default behaviour) --help Shows a simple help screen EXAMPLES
Running hackbench without any options will give default behaviour, using fork() and sending data between senders and receivers via sockets. user@host: ~ $ hackbench Running in process mode with 10 groups using 40 file descriptors each (== 400 tasks) Each sender will pass 100 messages of 100 bytes Time: 0.890 To use pipes between senders and receivers and using threads instead of fork(), run user@host: ~ $ hackbench --pipe --threads (or hackbench -p -T) Running in threaded mode with 10 groups using 40 file descriptors each (== 400 tasks) Each sender will pass 100 messages of 100 bytes Time: 0.497 Set the datasize to 512 bytes, do 200 messages per sender/receiver pairs and use 15 groups using 25 file descriptors per child, in process mode. user@host: ~ $ hackbench -s 512 -l 200 -g 15 -f 25 -P Running in process mode with 15 groups using 50 file descriptors each (== 750 tasks) Each sender will pass 200 messages of 512 bytes Time: 4.497 AUTHORS
hackbench was written by Rusty Russell <rusty@rustcorp.com.au> with contributions from Yanmin Zhang <yanmin_zhang@linux.intel.com>, Ingo Molnar <mingo@elte.hu> and David Sommerseth <davids@redhat.com> This manual page was written by Clark Williams <williams@redhat.com> and David Sommerseth <davids@redhat.com> HISTORY
This version of hackbench is based on the code downloaded from http://people.redhat.com/mingo/cfs-scheduler/tools/hackbench.c. Yanmin Zhang merged the original hackbench code from http://devresources.linuxfoundation.org/craiger/hackbench/src/hackbench.c which uses fork() and a modified version from http://www.bullopensource.org/posix/pi-futex/hackbench_pth.c which uses pthread only and gave the possibility to change behaviour at run time. Hackbench have since then gone through some more rewriting to improve error handling and proper tracking of fork()ed children, to avoid leaving zombies on the system if hackbench stops unexpectedly. February 23, 2010 hackbench(8)
All times are GMT -4. The time now is 08:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy