I have developed a Bash script that accepts parameters:
$ head -n 3 MyScript.sh #!/usr/bin/env bash # This is my script #... do something
I call it via CRON at different scheduling and with different parameters:
$ crontab -l * * * * * MyScript.sh 1 -t 600 */2 * * * * MyScript.sh 40 */3 * * * * MyScript.sh 41,42 */5 * * * * MyScript.sh 61 * * * * * MyScript.sh 21
When wanting to know what instances are running (the script is not very long, just a few seconds of execution):
$ pgrep -f -a -l "MyScript.sh" 25003 /bin/sh -c MyScript.sh 21 25005 /bin/sh -c MyScript.sh 41,42 25006 bash /bin/MyScript.sh 21 25007 bash /bin/MyScript.sh 41,42 25008 /bin/sh -c MyScript.sh 40 25009 bash /bin/MyScript.sh 40 25010 /bin/sh -c MyScript.sh 1 -t 600 25012 bash /bin/MyScript.sh 1 -t 600
We can see in the above example the
MyScript.sh 21 (and any other) instance apparently running twice, one of them started via
bash and the other one via
/bin/sh -c . Both do start and finish at the same time, as I have confirmed with
I am performing these tests in RaspBian (Debian based).
Here below is a example of what happens when running the same script on FreeBSD:
$ pgrep -f -a -l "MyScript.sh" 78230 bash /bin/MyScript.sh 103 78106 bash /bin/MyScript.sh 470 77484 bash /bin/MyScript.sh 2 77430 bash /bin/MyScript.sh 451 77019 bash /bin/MyScript.sh 52 76922 bash /bin/MyScript.sh 101 -v -d 76642 bash /bin/MyScript.sh 1 -t 600 76174 bash /bin/MyScript.sh 102 -v -d
As can be seen, BSD doesn't have these repeated instances.
Why is this happening on RaspBian and how could I solve it? Actually, do I need to "solve" it at all?