I want to put a check in my script to check if the same instance is already running and not finished and if not then does not allow it to run! in which part of my script I should put this? and any idea how I should write it? tx
Your question confuses me a little. But the short answer is:
Create a lock file. This file has one single entry, the pid of the process running your script. If the file is "blank" then no script is running. If the file has a pid, but the pid (if it exists) is not running your script, then the previous version of the script crashed.
Make SURE you have only one place, one exit point for a succesful completion.
Put two entries the the file:
this one goes at the very beginning - this will work in ksh or bash:
one line before the one and only successful exit point:
This User Gave Thanks to jim mcnamara For This Post:
---------- Post updated at 06:32 AM ---------- Previous update was at 04:27 AM ----------
I understood them myself.
can I ask a general question?
Guys I always have a starting and kick off problem!! on how to start a script?!!! I have some skills to write the script but the kick-off is always a problem for me!!!
this really makes me sad!!!
Linux System having all Perl, Python, PHP (and Ruby) installed
From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file
eg
eg
a Shell script run in a case statement call to run a php file, also Perl or/and Python file???
Like
#!/usr/bin/bash
....
....
case $INPUT_STRING... (1 Reply)
Hi Team,
Am getting the below output but need the count of records to be displayed in same line but currently count alone moves to next line. Please let me know how we can still keep the count in the same line.
######code #####
while read YEAR; do
for i in TEST_*PGYR${YEAR}_${DT}.csv; do... (3 Replies)
Hello all,
I'm trying to write a script to gather and send data and it works just fine at the bash command line, but when executing from CRON, it does not run properly.
My scripting skills are pretty limited and there's probably a better way, but as I said it works at the command line, but... (12 Replies)
In bash shell, how we can avoid the commands getting recorded in history file.
One way i can think of is :
export HISTSIZE=0
Is there any other way to achieve this?
Thanks (1 Reply)
Hi,
I have a script which has the below line:
ps -ef | grep ${SCRIPT_NAME} | grep ksh | grep -v grep >> /tmp/instance.tmp
When the script is invoked through CRON, I get 2 lines in instance.tmp when actually only one instance is running:
cdrd 17790 17789 0 15:14:01 ? 0:00 /bin/ksh... (8 Replies)
how to run an already developed script run against a list of ip addresses solaris 8 question.
the script goes away and check traffic information, for example
check_GE-VLANStats-P3 1.1.1.1
and returns the results ok.
how do I run this against an ip list? i.e a list of 30 ip addresses (26 Replies)
I am looking to a solution to the following problem. I have a very large file that looks something like this:
Each group of three numbers on each line are three probabilities that sum to one.
I want to output the maximum for each group of three. So desired output would be:
or... (6 Replies)
In my cronjob, I would like to schedule my script.sh to run every minutes. I crontab -e and have in line below but it didn't seems to run at all.
* * * * * script.sh
When I run it manually, I can run it. Is that anything wrong with the above line?
If I change it to something like below,... (4 Replies)
Hi,
Would like to ask the experts if anyone knows how to run a script like this:
dtterm -title shell1
run process1 on shell1
dtterm -title shell2
run process2 on shell2
cheers!
p/s: sorry if i used the wrong forum, quite concussed after watching world cup for several nights; but I... (2 Replies)