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
What have you tried?
I joined the two into a single script, but it does not work
Instead of joining 2 scripts, you can write another caller script which will invoke test1 & test2 every 3 minutes:-
#!/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
2 Likes
As long as the scripts take less then 3 minutes this should fire every 3 minutes..
while :
do
sleep 180 & # Run sleep in the background
/path/to/dir/test1
/path/to/dir/test2
wait # wait for sleep to finish
done
2 Likes
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
Crontab -e
*/3 * * * * /Path to script test3.sh
I'd really recommend doing this in cron rather than an infinite while loop....especially if you literally want it to be every three minutes.
This is the kind of thing cron is made for.