I am trying to make a script which should execute if the same is not getting executed already.
To implement this check, I wrote a fragment of code as below
On execution the output is as below [using -x for verbose purpose]
However during this sleep time if I am checking the process count from another terminal it gives me check=1
Unable to understand why this difference, please help
say when you run the ps -ef under backquotes it will run it under subshell and command would be fired and captured by same ps -ef so it will give 2 as output
The problem may be that sometimes the grep process is spotted too, which you are trying to handle. Could you consider using the -c flag of grep and neatening your code a bit?
The square brackets mean that the contents are a range of characters, in this case only h which might seem a little odd, but it means that your grep will not find itself. The count is a function of grep
Can you have a go with the above streamlined code and if it's still confusing, take the -c flag off and show us the output.
Can you insert the lines:-
above the active check=`ps .... and post the output. I'd like to see what is 'us' and what is not. There is no need to set the value of check to zero before you start. If grep -c does not match anything, it will return the value zero.
I'm a bit confused, I must admit. On AIX I get:-
.....yet on RHEL I get:-
.... and on HP-UX it's the same:-
What OS are you using.
Hi guys,
I'm writing a script on a Solaris 10 server (server A) that needs to telnet 2 servers (server B & server C) and get a certain process count from these 2 servers.
Then on server A, I check if both counts are greater than 17, I do a sendmail to concerned people.
For the telnet part,... (7 Replies)
Hi,
I have a file with contents
So what I have to do is
In short, break the file after every 6 lines and then truncate new line to tab for these 6 lines.
I am not able to execute the for loop in awk properly.
The idea is something like this:
less file| awk '{for .... {if ((nr>=1)... (7 Replies)
Hi,
We have scheduled few jobs/scripts in cron and it runs on daily basis at a specified time. We have a cron jobs has various parameters for main scripts like
/home/test/mainscript.ksh main_param
when the above jobs triggers, mainscript.ksh has below code and it refers
... (3 Replies)
Hello Everyone,
I have a process that should be always running. Unfortunately, this process is getting down almost every 10 minutes. I want to make a script that verify the state of this process: If the process is up, the script shouldn't do nothing and if it's down he should run it.
Can... (3 Replies)
i have something like this
tablesName="abc def hij akn ... etc etc"
count=0
for i in $tablesName
do
echo -en "\b\b\b\b\b\b\b\b\b\b\b\b\bTableCount: $count"
count=`expr $count + 1`
done
the above is just a description wha i need is when the loop executes
the... (1 Reply)
Hello all,
I would be happy if any one could help me with a shell script that would determine all the processes running on a Unix server and post a mail if any of the process is not running or aborted.
Thanks in advance
Regards,
pradeep kulkarni.
:mad: (13 Replies)
hey all,
i am working on sun solaris machine and i want to start a process in background using shell script (actually i wanna start tomcat server using shell script). please dont tell me that append a & at last because this is not working in the shell script. i have also used nohup and... (8 Replies)
I am trying to find out that how many number of threads are currently running or in any other state which is created by POSIX standard in a process.
First I have defined a variable called proc_var of type proc defined in sys/proc.h.Next I open up the dir /proc and per directory wise I do an ioctl... (7 Replies)