Sponsored Content
Top Forums Shell Programming and Scripting How to check the status of script for every 5 min? Post 302863821 by sea on Tuesday 15th of October 2013 07:19:09 AM
Old 10-15-2013
As it is the file same called, but with a diffrent argument, it depends if also the first argument should be forced to 'sleep' until the lockfile is gone...

In that case it could look simliar:
Code:
#!/bin/sh
LOCKFILE=/opt/app/dev/load_cdr.lock
FIXSTR="-bkm.dat"

[[ -z $1 ]] && echo "No args supplied";exit 1;
while [[ -f $LOCKFILE ]];do sleep 5M;done

case "$1" in
"A")	touch $LOCKFILE
	echo "Parsing $1$FIXSTR"
	sleep 30
	rm $LOCKFILE
	;;
"B")	echo "Parsing $1$FIXSTR"
	rm $LOCKFILE
	;;
esac

Hope this helps
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

how to check exit status in awk script

Hi, I have a main program which have below lines - awk -f test.awk inputFileName - I wonder how to check status return from awk script. content of awk script: test.awk --- if ( pass validation ) { exit 1 } else { (1 Reply)
Discussion started by: epall
1 Replies

2. Shell Programming and Scripting

Script to check status of a PID

i'm just learning scripting, and have been banging my head against this I want to check if my WAS6 java process is running and if so..echo me a messages. If not then echo me a different messages the problem i have is I dont know how to represent a NULL return value. If i grep for a was6... (14 Replies)
Discussion started by: zeekblack
14 Replies

3. Shell Programming and Scripting

check exit status - Expect Script

from my main script, i am calling an expect script. there are a lot of conditions in the Expect script and it can have any exit value based on success or failure of the Expect Script. how can i check the exit status of Expect scritp in the main script. (1 Reply)
Discussion started by: iamcool
1 Replies

4. UNIX for Dummies Questions & Answers

unix script to check if rsh to box and send status mail

rshstatus=`rsh -n lilo /db/p2/oracle/names9208/restart_names.sh` if $rshstatus <>0 then errstatus=1 mailx -s "xirsol8dr" ordba@xxx.com >> $log_dr else if errstatus=0 echo "status to xirsol8dr successful" can anyone provide if this is t he correct way to do this or is there a better way? (1 Reply)
Discussion started by: bpm12
1 Replies

5. UNIX for Dummies Questions & Answers

SFTP script - poll every min to check file complete before transfering

Hello, Before I do a GET remote file, I need to ensure the remote file is a complete file i.e. whatever process is saving the file to the remote folder should complete the transfer before I go GET it through my script. So I'm thinking I need to poll the remote file every minute or so to... (4 Replies)
Discussion started by: srineel
4 Replies

6. Shell Programming and Scripting

Automation, Copy, File Status Check --> Script(s)

All, I have to write a script to do the following requirement. There is a file called BUSINESS_DATE.TXT. This file get updated once the oracle partition created. In Oracle, Partition will be created every day. There is a seperate script scheduled to take care ORACLE partition creation. The... (3 Replies)
Discussion started by: karthi_mrkg
3 Replies

7. Shell Programming and Scripting

Help....script check status if see something then send email

autorep -m bogus Machine Name Max Load Current Load Factor O/S Status ___________ ________ ___________ ______ ________ ______ bogus --- --- 1.00 Sys Agent Online Status ______ Online Offline Missing Unqualified The "Status" always "Online". I like create a script execute run... (6 Replies)
Discussion started by: dotran
6 Replies

8. Linux

Check up the status of a Script (running or not)

Hello, i allready search on google und here in the local Forum, but can't found something. I need a query in php, that check whether a process (script) is running or not. Like this: php query: /usr/bin/Script01 >> if runnig, then: "Script01 is Online", if not "Script01 is Offline" I... (2 Replies)
Discussion started by: ProTechEx
2 Replies

9. Shell Programming and Scripting

UNIX script to check multiple jobs runninng status

Hi Folks, Please help me ,I need a unix shell script to check for multiple jobs running. if there are multiple backup Jobs running then it should be trigger an email . Thanks, Anand T (1 Reply)
Discussion started by: nandu67
1 Replies

10. Shell Programming and Scripting

Script to check process status

Hi Team, I am using redhat 6.4 version server.We have a script which is used to check the process and sends email if the process is not running.If it is running it will continue and do some other operation. I didnot understand below option -z in the if condition.I have tried to... (5 Replies)
Discussion started by: muraliinfy04
5 Replies
LOCKFILE(1)                                                   General Commands Manual                                                  LOCKFILE(1)

NAME
lockfile - conditional semaphore-file creator SYNOPSIS
lockfile -sleeptime | -r retries | -l locktimeout | -s suspend | -! | -ml | -mu | filename ... DESCRIPTION
lockfile can be used to create one or more semaphore files. If lockfile can't create all the specified files (in the specified order), it waits sleeptime (defaults to 8) seconds and retries the last file that didn't succeed. You can specify the number of retries to do until failure is returned. If the number of retries is -1 (default, i.e., -r-1) lockfile will retry forever. If the number of retries expires before all files have been created, lockfile returns failure and removes all the files it created up till that point. Using lockfile as the condition of a loop in a shell script can be done easily by using the -! flag to invert the exit status. To prevent infinite loops, failures for any reason other than the lockfile already existing are not inverted to success but rather are still returned as failures. All flags can be specified anywhere on the command line, they will be processed when encountered. The command line is simply parsed from left to right. All files created by lockfile will be read-only, and therefore will have to be removed with rm -f. If you specify a locktimeout then a lockfile will be removed by force after locktimeout seconds have passed since the lockfile was last modified/created (most likely by some other program that unexpectedly died a long time ago, and hence could not clean up any leftover lock- files). Lockfile is clock skew immune. After a lockfile has been removed by force, a suspension of suspend seconds (defaults to 16) is taken into account, in order to prevent the inadvertent immediate removal of any newly created lockfile by another program (compare SUSPEND in procmail(1)). Mailbox locks If the permissions on the system mail spool directory allow it, or if lockfile is suitably setgid, it will be able to lock and unlock your system mailbox by using the options -ml and -mu respectively. EXAMPLES
Suppose you want to make sure that access to the file "important" is serialised, i.e., no more than one program or shell script should be allowed to access it. For simplicity's sake, let's suppose that it is a shell script. In this case you could solve it like this: ... lockfile important.lock ... access_"important"_to_your_hearts_content ... rm -f important.lock ... Now if all the scripts that access "important" follow this guideline, you will be assured that at most one script will be executing between the `lockfile' and the `rm' commands. ENVIRONMENT
LOGNAME used as a hint to determine the invoker's loginname FILES
/etc/passwd to verify and/or correct the invoker's loginname (and to find out his HOME directory, if needed) /var/mail/$LOGNAME.lock lockfile for the system mailbox, the environment variables present in here will not be taken from the environment, but will be determined by looking in /etc/passwd SEE ALSO
rm(1), mail(1), sendmail(8), procmail(1) DIAGNOSTICS
Filename too long, ... Use shorter filenames. Forced unlock denied on "x" No write permission in the directory where lockfile "x" resides, or more than one lockfile trying to force a lock at exactly the same time. Forcing lock on "x" Lockfile "x" is going to be removed by force because of a timeout (compare LOCKTIMEOUT in procmail(1)). Out of memory, ... The system is out of swap space. Signal received, ... Lockfile will remove anything it created till now and terminate. Sorry, ... The retries limit has been reached. Truncating "x" and retrying lock "x" does not seem to be a valid filename. Try praying, ... Missing subdirectories or insufficient privileges. BUGS
Definitely less than one. WARNINGS
The behavior of the -! flag, while useful, is not necessarily intuitive or consistent. When testing lockfile's return value, shell script writers should consider carefully whether they want to use the -! flag, simply reverse the test, or do a switch on the exact exitcode. In general, the -! flag should only be used when lockfile is the conditional of a loop. MISCELLANEOUS
Lockfile is NFS-resistant and eight-bit clean. NOTES
Calling up lockfile with the -h or -? options will cause it to display a command-line help page. Calling it up with the -v option will cause it to display its version information. Multiple -! flags will toggle the return status. Since flags can occur anywhere on the command line, any filename starting with a '-' has to be preceded by './'. The number of retries will not be reset when any following file is being created (i.e., they are simply used up). It can, however, be re- set by specifying -rnewretries after every file on the command line. Although files with any name can be used as lockfiles, it is common practice to use the extension `.lock' to lock mailfolders (it is ap- pended to the mailfolder name). In case one does not want to have to worry about too long filenames and does not have to conform to any other lockfilename convention, then an excellent way to generate a lockfilename corresponding to some already existing file is by taking the prefix `lock.' and appending the i-node number of the file which is to be locked. SOURCE
This program is part of the procmail mail-processing-package (v3.22) available at http://www.procmail.org/ or ftp.procmail.org in pub/proc- mail/. MAILINGLIST
There exists a mailinglist for questions relating to any program in the procmail package: <procmail-users@procmail.org> for submitting questions/answers. <procmail-users-request@procmail.org> for subscription requests. If you would like to stay informed about new versions and official patches send a subscription request to procmail-announce-request@procmail.org (this is a readonly list). AUTHORS
Stephen R. van den Berg <srb@cuci.nl> Philip A. Guenther <guenther@sendmail.com> BuGless 2001/06/23 LOCKFILE(1)
All times are GMT -4. The time now is 09:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy