Reputation: 15
I have a crontab entry that will run a 'worker' script hourly. Within the 'worker' script I have multiple paths to other scripts like so;
#!/bin/bash
clear
echo "project-worker"
echo "Script to run checks on all jobs!"
source /home/user/project/project-jobs/cleanuptest1/project-mon-cleanuptest1.sh
source /home/user/project/project-jobs/sedtest1/project-mon-sedtest1.sh
jobslot=empty
exit
My issue is it only seems to be running the first script (cleanuptest1.sh) and ignoring the rest. Can anyone see where I'm going wrong at all? I read to call other scripts from within a script I should use source
but is where I'm going wrong, it can't be used for multiple instances?
Many thanks in adavance!
Upvotes: 0
Views: 51
Reputation: 4855
Source should only be used if you need to preserve the called script environment on the callee.
If that's not the case you can execute the subscripts in subshells.
#!/bin/bash
clear
echo "project-worker"
echo "Script to run checks on all jobs!"
bash /home/user/project/project-jobs/cleanuptest1/project-mon-cleanuptest1.sh
bash /home/user/project/project-jobs/sedtest1/project-mon-sedtest1.sh
jobslot=empty
exit
Upvotes: 3