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
main_param="param1 param2 param3 param4"
the script1.ksh triggeres one by one for these params like script1.ksh param1 (once it finishes its execution), then it triggers script1.ksh param2
So, consider script1.ksh param1 is still running till next day the same param1 triggers (as said cron jobs runs on daily basis), it overlaps the logs and makes more usage in the database/server.
In order to avoid that, I have included the below code
It was running perfect in Sun solaris box, but in AIX, it started misbehaving like when the next param runs on the same day, it says that älready process is running"
script1.ksh param1 -- after it completion, it says that script1.ksh param2 is running (more than 1 instance condition) but there is no chance of param2 is running currently.
I have checked the condition as $check -gt 2, but it throws the message rarely that "Already process running"
Please help me to identify the correct process and throw this message.
your timely help is much appreciated as I m in the neck moment.
You avoid the ps | grep | grep | awk | sed | cut | wc -l | kitchen | sink junk as well as implementation-dependent ps difference problems, by using PID files.
The trap .......... EXIT is very useful, but make sure that your code does not exec another program or reset the traps anywhere or you will not clean up the file. I've fallen over that one.
Also be sure that you don't have something that cleans up /tmp as I have fallen over this before when someone thought it would be a good idea to remove temporary files at 2am every night. It gets worse when the schedule runs late, but it's all so badly written that we need something to clean up every now and then so without a huge re-write of the schedule we're stuck. Can you see I'm experienced in it all going wrong?
This is still a much better idea than just counting processes, as Corona688 says. Of course, you need to ensure that /tmp/myscriptlock is unique in every script. Perhaps you could base it on the script actually running with something like:-
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,
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
$ cat abc.sh
#!/bin/bash
check=0
#grepping "sh -x abc.sh" because if i check only for "abc.sh" and the file is open in say... (12 Replies)
Hi all
I have an input file which contains so many entries like this: And, I want to count hw many among ASN in one column are converted to LYS in third coulmns. which means output shuld contain only "ASN number LYS"
Kindly let me know wny programm for this
My input is
ASN 217 LYS... (2 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)
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)
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)