0

We have scheduled test suite command for mutliple setups means dev and staging, prod setups in cron job with bash script.

Daily it is running one after another. we need to run all test suites with different setups with same time(parallely)

I am running that command in Cron with bash script.

setup_wise_test.sh

setup_wise_test, In sh bash script the following commands are present. script 1 script 2 script 3 upto script 8 with different setup related test cases.

Each one is taking maximum of 45 minutes(selenium test cases). If I schedule all one after one, it's taking more than 6 hours 40 minutes to complete all.

Hence, plese help me out by suggesting the way to run all commands in bash as parallelly.

  • When I ran like below

    21 13 * * * user cd /home/common_setupwise_testcases && bash sample1.sh >> /home/cron_logs/common_setup_wise_logs/sample.log

    21 13 * * * user cd /home/common_setupwise_testcases && bash sample2.sh >> /home/cron_logs/common_setup_wise_logs/sample2.log

    21 13 * * * user cd /home/common_setupwise_testcases && bash sample3.sh >> /home/cron_logs/common_setup_wise_logs/sample3.log

in the above sample1.sh, sample2.sh sample3.sh is having run command for test cases.

When i scheduled all above 3 commands in cron(sample1.sh and sample2.sh) executed parallelly third one is not executed.

  • 1
    Is there maybe a syntax error in script3 which prevents it from being run? Is there something in the log? – malte Oct 24 '17 at 12:33
0

There is your answer from unix.stackexchange:

https://unix.stackexchange.com/questions/287166/how-to-run-multiple-scripts-at-a-same-time

Short example, put it in 'crontab -e' of your user, who is supposed to run those jobs:

0 15 * * 6 job1
0 15 * * 6 job2
0 15 * * 6 job3

EDIT1 for @Mounika K

I've tried with very simple script:

$ cat job1.sh 
#!/bin/bash
yes > /dev/null 2>&1

And tried to run as crontab entry:

22 * * * * /var/tmp/job1.sh
22 * * * * /var/tmp/job2.sh
22 * * * * /var/tmp/job3.sh

As expected, there are 3 instances of yes program running in the background. Check if cron is allowed for users on your system.

| improve this answer | |
  • I Tried as you mentioned in above comment. But it's not working properly. I edited my post. can you please read and post your suggestions on that. – Mounika K Oct 24 '17 at 12:12
  • @MounikaK I've doublechecked and it works. See the edit I've just made. – Jaroslav Kucera Oct 24 '17 at 19:30
-2
21 13 * * * command1 &; command2 &; command3 &
| improve this answer | |
  • Again: Please read the question carefully before answering. What you propose will run the commands sequentially, which is exactly what OP doesn't want to do. – Sven Oct 24 '17 at 14:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.