I have 4 scripts say SA , SB ,SC AND SD..I need to achieve the conditions below via CRONTAB:
1) SA will trigger by SB
2) SA should not run in parallel with SC and SD.
3) IF any of SC OR SD is RUNNING SA will wait for them to complete and run after their completion. Same for SC and SD ( IF SA is RUNNING)
I think it can be achieve by grepping the process in each script and wait till no process found ( I am not sure if wait will work here),but I have restriction to change the script so if this can be done with crontab it will be GREAT.
You are trying to set up something that allows process synchronization. This is usually achieved using some kind of IPC mechanism (Inter-process communication). You can use a lockfile.
Let's have three scripts: SA, SB, SC. you need to have a shell function or a bit of code to implement this. It is easier to control if each process uses PRECISELY the same mechanism to control its successors. Consider a lockfile.
crontab: run all three scripts at 2:20 am (example)
SA:
SB:
SC:
This User Gave Thanks to jim mcnamara For This Post:
You could write a script that will run the other SB, SA, SC, and SD guaranteeing that SA completes before SC and SD start, allowing SB, SC, and SD to run in parallel, and guaranteeing that only one copy of the script runs at a time without modifying SA, SB, SC, or SD. One way to do this is:
Note that when started by cron, your environment will not be initialized as it would be if you had logged in and started it from your shell. If SA, SB, SC, and SD need to have any environment variables set, you will need to set those variables in the start of this script before they are invoked.
This script exits if another copy of the script is still running. If you want it to enter an idle loop until the prior script completes, you can replace the if, then, else with a while, do, done and the exit with a sleep.
This script was tested with both ksh and bash. The way it sets $IAm will not work with an original Bourne shell. (There may also be other standard features used by this script that the Bourne shell does not support.)
This User Gave Thanks to Don Cragun For This Post:
Thanks Don.. So I have two options now , one to change script with grepping process ID before start and one is to create a new script ... Let me see which will be feasible in my case.. Thanks much and YES this is the only site where I get my answer always...
After you have modeled your dependencies using the lock modes developed by Distributed Lock Manager (see Wikipedia) you could use FLOM (Free LOck Manager) to achieve your result.
With FLOM you are able to execute a command specifying an abstract resource and a lock mode for every command:
Hi 2 all,
i have had AIX 7.2
:/# /usr/IBMAHS/bin/apachectl -v
Server version: Apache/2.4.12 (Unix)
Server built: May 25 2015 04:58:27
:/#:/# /usr/IBMAHS/bin/apachectl -M
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
mpm_worker_module (static)
... (3 Replies)
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
logs:
"/home/abc/public_html/index.php"
"/home/abc/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
how to use "cut" or "awk" or "sed" to get the following result:
abc
abc
xyz
xyz
xyz (8 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hello.
I have a slackware system running cups with an HP laserJet 2100 connected via parallel port in ECP mode. Print jobs are working. Very slowly.
15K test print out of cups takes about 2 minutes to complete.
When the printout is on the way to the printer, the process "parallel" uses... (0 Replies)
heya,
can someone help me with following problem.
i am not sure how far you know the catalina.sh script from tomcat. when i start my tomcat with "catalina.sh run" then the startup-process-output will be printed out on the console, but the tomcat process is started in current shell/session, so... (1 Reply)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)
Hello All.
I'm get the following messages posted to the /var/adm/syslog file ever second and not sure on how to stop the process.
May 14 15:50:52 a3360 bootpgw: version 2.3.5
May 14 15:50:52 a3360 inetd: /etc/bootpgw exit 0x1
As said about this gets logged every second only thing that... (4 Replies)