Applicable to:
- Plesk for Linux
Symptoms
-
When executing a scheduled task that runs a command to execute a script in Plesk, it returns a Permission denied error:
PLESK_ERROR: Task " php -q /var/www/vhosts/example.com/httpdocs/wp-cron.php" completed with error in 0 seconds, output:
-: /dev/null: Permission denied
PLESK_ERROR: Task " php -q /var/www/vhosts/example.com/httpdocs/wp-cron.php" completed with error in 0 seconds, output:
-: php: command not found
Cause
Lack of permissions on the script file or missing command in the chroot environment.
Resolution
-
Change the shell for the subscription to /bin/bash in Subscriptions > example.com > Web Hosting Settings > Access to the server over SSH.
Note: The next step is not necessary in case the executable file cannot be accessed via Plesk File manager.
-
Correct permissions or task type.
Comments
7 comments
Hi, I manage to get .PHP files working with the schedule tasks, yet, with .SH files I can't. You example shows a .SH file but the CRON you used is a PHP. That is not correct.
Can someone help me get this code working:
* * * * * ! test -e /var/www/vhosts/YOURSITE/httpdocs/maintenance.flag && /bin/bash /var/www/vhosts/YOURSITE/httpdocs/scheduler_cron.sh --mode always
[image delete for security reasons]
Hi there ignacio correia!
Thanks for your question.
Can you please share:
- a screenshot of the scheduled task settings in Plesk when you try to schedule a shell script
- the message you get when the task fails to run
Thanks,
Kuzma
Notice this: https://docs.plesk.com/en-US/12.5/deployment-guide/upgrading-plesk/completing-upgrade-from-plesk-9-and-earlier-versions/execution-of-scripts-via-cron-task-scheduler-linux-hosting.66791/
I need /bin/bash at a domain level otherwise won't work, right?
Hello,
I have same issue but i cannot fix it. I followed this but no luck, some one help me?
Hi Buyanbat Ulziikhuu, after applying the solution are you getting the same error? Which one exactly?
I recommend opening a support ticket so we can investigate this https://support.plesk.com/hc/en-us/articles/213608509-How-to-submit-a-request-to-Plesk-support-
Hello, I had a similar problem.
To run php in the command I did the following:
1: /opt/plesk/php/7.3/bin/php (here your command or route)
2: Then I connected by SSH and entered the console.
3: Activate the cronjob with the following command
3.1: # systemctl enable crond
3.2: # systemctl start crond
So my problem was solved, I hope to help someone with my contribution. A greeting! :)
Carlos Donado Felices Hi! thanks for that. But i believe in your case you had a different scenario where crond was disabled. Thanks again for sharing!
Please sign in to leave a comment.