Sometimes, you have a shell script that you wish to run only if one isn’t already running. For example, you usually don’t want your script to run until the other one is done, and sometime the script (or a sub-script) isn’t smart enough to that.
Other than better coding, one way to do this is by using a shell wrapper to start the script:
#!/bin/sh if ps -ef|grep -v grep|grep cron.php;then exit 0 else php /var/www/html/nextcloud/cron.php exit 0 fi
…in this example, we are using grep to see if the end task is running (while avoiding grep itself) and if it is not, we run the target.