How to couple 2 script in 1?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to couple 2 script in 1?
# 1  
Old 12-03-2012
How to couple 2 script in 1?

I have two script / test1 - test2
test1 in var / etc
test2 in var / www
and I want coupled into a single script that runs both script in the following order test1 and test2 every 3 minutes

Last edited by azzeddine2005; 12-03-2012 at 04:04 PM..
# 2  
Old 12-03-2012
What have you tried?
# 3  
Old 12-03-2012
I joined the two into a single script, but it does not work
# 4  
Old 12-03-2012
Instead of joining 2 scripts, you can write another caller script which will invoke test1 & test2 every 3 minutes:-
Code:
#!/bin/ksh
while (true)         # Infinite while loop
do
   /etc/test1        # Running test1
   /www/test2        # Running test2
   sleep 180         # Sleeping for 3 minutes.
done

OR you can schedule them in cron
These 2 Users Gave Thanks to Yoda For This Post:
# 5  
Old 12-03-2012
As long as the scripts take less then 3 minutes this should fire every 3 minutes..
Code:
while :
do
  sleep 180 &          # Run sleep in the background
  /path/to/dir/test1
  /path/to/dir/test2
  wait                 # wait for sleep to finish
done


Last edited by Scrutinizer; 12-03-2012 at 06:54 PM..
These 2 Users Gave Thanks to Scrutinizer For This Post:
# 6  
Old 12-04-2012
You can also use crontab utility for this
First Put your script into one single script and then edit the crontab
Suppose the new name of the script containing both of your script is test3.sh

Code:
 Crontab -e
*/3 * * * * /Path to script test3.sh

# 7  
Old 12-04-2012
thank you mr bipinajith
it work fin
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script using expect to login to couple of remote servers and read "crontab -l"

I need a shell script using expect to login to couple of remote servers and read "crontab -l -u <username>" & "cat /etc/rc.local" & "df -h" and able to create output into a file saved locally with hostname.crontab & hostname.rc.local & disk.status. I can supply a file as list of hostname or IP... (4 Replies)
Discussion started by: jaipsharma
4 Replies

2. Shell Programming and Scripting

A couple issues

Hello, I have a couple questions. First of all, I'm trying to use the wc command on the /etc/passwd file to find out the total amount of users but I am unsuccesful. I figured since users each have their own line in the passwd file that i could have it count the number of lines and then return the... (1 Reply)
Discussion started by: Simonpalmieri
1 Replies

3. Solaris

Couple logadm questions

My logadm.conf is below. Is there a way to match a log file that appends the time/date stamp after the log file? Also, a 0 is being appended onto the files I'm compressing and having rotated. Is there a way to fix that? /var/apache/tomcat55/logs/catalina.out -C 30 -P 'Fri Jun 18 16:48:55... (5 Replies)
Discussion started by: LittleLebowski
5 Replies

4. HP-UX

Couple of questions.

Right now I am a Microfocus COBOL programmer, working on a HP-UX system. I want to now get Certified as a HP Certified Systems Administrator. I ordered a book from amazon and will start with it. I also will be working at my job with someone who applies the patches and things as we do NOT have a... (3 Replies)
Discussion started by: nixie21
3 Replies

5. Shell Programming and Scripting

need couple of ksh tricks please

1) I ran myScript with 2 arguments, I meant to use 3 if I do r my, it will rerun it with the 2 arguments. is there a way I can do r my and add a third argument at the end? 2) say I did myAcript.ksh 2 5 7 8 I realise my typo. is there an easy way to redo the command replacing A with S? ... (4 Replies)
Discussion started by: JamesByars
4 Replies

6. Debian

A couple of grub questions.

1) After I install a new kernel in Debian Sarge, it updates my menu.lst file for grub, but incorrectly. It assumes it should boot from partition hd0,0, but this is incorrect. How do I change this faulty assumption? 2) If grub fails to find a kernel, grub allows me to enter a path to... (1 Reply)
Discussion started by: akbar
1 Replies
Login or Register to Ask a Question