Issue
I just got in a trouble, i were trying to make cronjob to run every 5 minutes, and within php i tried to check if my script is already running, if yes: exit, otherwise continue with running. Everything went good until i let cron job to run script, and then it started to run at every 5 minutes (*every time it runned, and i got few scripts running in background instead of planned only 1), but when i try to run the script from browser it returns good and recognize all running scripts.. I tried to log results and got that script runned from cronjob using following code:
$php_search = "connect.php";
$result = shell_exec("ps aux | grep -v grep | grep ".$php_search );
/* checking result & code for listening connection -- forever running */
gets only as result the current running cronjob (not the other that is already running in background). For example if the cron job runned this script for 5 times, even the 6th run would return as result just itself nothing else from running scripts?
Result:
..... 1 0.0 0.0 20164 244 ? S 09:40 0:00 jailshell (.....) [init] ell -c /usr/bin/php /home/...../public_html/...../connect.php
..... 2 0.0 0.0 361412 15444 ? S 09:40 0:00 /opt/cpanel/ea-php56/root/usr/bin/php-cgi /home/...../public_html/...../connect.php
Am i doing something wrong with grep
or there is some limitation within cronjob as it works when i run the script through browser?
I am using dedicated server, so if there's some option i could change i can do it...
Thanks.
Solution
I've managed to get it working, and it was option on root account (whm) following menu:
Account Functions -> Manage Shell Access
There i have just turned shell access for account from Disabled Shell to Normal Shell
And now it works and grep
get's all other running scripts..
Answered By - Ultrazz008 Answer Checked By - Robin (WPSolving Admin)