Author Topic: cron task not executed manually  (Read 2559 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
cron task not executed manually
« 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
« Last Edit: March 30, 2022, 08:20:38 AM by ptidav »

Offline
****
Re: cron task not executed manually
« Reply #1 on: March 30, 2022, 09:07:11 AM »
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.
Google Hangouts:  rcschaff82@gmail.com

Offline
*
Re: cron task not executed manually
« Reply #2 on: March 31, 2022, 07:05:49 AM »
Ok but why there is button in the gui called "run cron job now" with a right arrow icon ?
Thanks

Offline
****
Re: cron task not executed manually
« Reply #3 on: March 31, 2022, 10:06:12 AM »
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.
Google Hangouts:  rcschaff82@gmail.com