Control Web Panel
WebPanel => CentOS Configuration => Topic started by: ptidav on March 30, 2022, 07:48:26 AM
-
Hello,
I defined some cron task in the user account (.sh scripts). Execute right is applied on each script file.
A typical entry is :
/home/user/public_html/crons/cron_test.sh >> /home/user/public_html/crons/cron_test.log 2>&1
Task is never executed, when I launch it manually from the panel gui.
Log file is not updated.
However, the task is correctly executed at defined time.
What's wrong ?
Thanks for your help
David
-
Cron tasks cannot be run manually. When you run the command from php, it's mimicking cron running, but it's actually php running the script. Could be a permission issue as to why it's not running. Check /usr/local/apache/domlogs/(domain).error.log to see why the script doesn't run when executed from web.
-
Ok but why there is button in the gui called "run cron job now" with a right arrow icon ?
Thanks
-
Because the button on the webpage invokes the same command that the crontab does. The issue is, that when you add a crontab, it is actually added to the users actual crontab on the system. However, when run manually, PHP tries running the command. Because the code is encrypted, I can't say as to why it doesn't work, but generally PHP uses "exec, system", or one of many commands to perform operations on the system. Generally though, PHP needs you specify full path (Ex: /bin/bash /full/path/to/script.sh), whereas crontab can simply execute the script directly.
That's why I mentioned checking the log. If you don't see anything in those logs, check /usr/local/cwpsrv/logs/ to see if there is anything there.