• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Resolved cPanel to Plesk Cron job

Sporttiger

New Pleskian
Server operating system version
Ubuntu 22.04.2 LTS
Plesk version and microupdate number
Version 18.0.53
Hello,
New here to the forum. I have been using cPanel for the last 15 years. I am moving my site to Ionos and have all files there. I have been trying to create the cron job I use on cpanel to Plesk but with no success. Here is the job that fetches every 30 minutes.

cd $HOME/public_html/River;php -q river-fetch.php > status.txt 2>&1

I have changed the public_html to httpdocs.
This is the message I get.
Task "cd $HOME/httpdocs/River;php -q river-fetch.php > status.txt 2>&1" completed with error in 0 seconds, output:
/bin/sh: 1: cd: can't cd to /root/httpdocs/River

Any help appreciated.

Thank you,
Alan
 
Try entering the fully qualified path like "cd /var/www/vhosts/<your subscription domain>/httpdocs/River..."
 
Try entering the fully qualified path like "cd /var/www/vhosts/<your subscription domain>/httpdocs/River..."
Thank you Peter, I had no clue on the /var/www/vhost. Where do you find information like that? I searched everywhere I thought.

Thanks again
Alan
 
A good start is the documentation https://docs.plesk.com/current . In the "Administrator Guide" you can find it here (for example):

Another fantastic resource is the Plesk Knowledge Base. Here is one article that will probably be of interest to you:
But there are many more to discover.
 
Try entering the fully qualified path like "cd /var/www/vhosts/<your subscription domain>/httpdocs/River..."
My site went live yesterday and the cron stopped working. Error below. This task is scheduled within my domain. If I go to tools & setting and setup the task it functions. It was working with the dummy site. Any help appreciated.

Task "cd /var/www/vhosts/mydomain.com/httpdocs/River;/opt/plesk/php/8.0/bin/php -q river-fetch.php > status.txt 2>&1" completed with error in 0 seconds, output:
-: line 1: cd: /var/www/vhosts/mydomain.com/httpdocs/River: No such file or directory
 
Rather than CD-ing into the directory, rewrite cron task as /opt/plesk/php/8.0/bin/php -q /var/www/vhosts/mydomain.com/httpdocs/River/river-fetch.php > status.txt 2>&1. Also, double check the River directory actually exists.
 
Rather than CD-ing into the directory, rewrite cron task as /opt/plesk/php/8.0/bin/php -q /var/www/vhosts/mydomain.com/httpdocs/River/river-fetch.php > status.txt 2>&1. Also, double check the River directory actually exists.
Ran with errors. River directory is there with the php file
 
Same error?

What happens if you connect to your server via SSH and run /opt/plesk/php/8.0/bin/php -q /var/www/vhosts/mydomain.com/httpdocs/River/river-fetch.php manually?
 
Same error?

What happens if you connect to your server via SSH and run /opt/plesk/php/8.0/bin/php -q /var/www/vhosts/mydomain.com/httpdocs/River/river-fetch.php manually?
Could not open input file. Just an other question how do you paste into SSH terminal? I right click to paste and not an option.

The error is not able to see details
 
Usually just ctrl + v (or cmd + v if you're on a mac).


I am not sure if I understand this correctly. If you run the command manually the error message you get is "not able to see details"?
Sorry for confusion.
You get
Could not open input file
 
Sorry for confusion.
You get
Could not open input file
No worries. I had to dig a little deeper to find a solution for you. I sometimes get confused with using cronjobs too.

You can use this command cd httpdocs/River;/opt/plesk/php/8.0/bin/php -q 'river-fetch.php' > status.txt 2>&1 in your cronjob. But in order for it to work you'll have the grant the domain system user SSH access with /bin/sh. You can do this in Plesk by navigating to the Hosting & DNS tab and clicking on Web Hosting Access. There you can select SSH access for the domain system user.
Schermafbeelding 2023-07-11 om 19.42.18.png
Edit: an explanation might be useful. So by default Plesk runs cron job commands in a Chroot environment which can't access the opt/plesk/php/x.x/bin/php directory nor does it understand fully qualified paths from the root directory. Giving the domains system user access to another environment will allow you to run the command without any restrictions.
 
Last edited:
No worries. I had to dig a little deeper to find a solution for you. I sometimes get confused with using cronjobs too.

You can use this command cd httpdocs/River;/opt/plesk/php/8.0/bin/php -q 'river-fetch.php' > status.txt 2>&1 in your cronjob. But in order for it to work you'll have the grant the domain system user SSH access with /bin/sh. You can do this in Plesk by navigating to the Hosting & DNS tab and clicking on Web Hosting Access. There you can select SSH access for the domain system user.
View attachment 23782
Edit: an explanation might be useful. So by default Plesk runs cron job commands in a Chroot environment which can't access the opt/plesk/php/x.x/bin/php directory nor does it understand fully qualified paths from the root directory. Giving the domains system user access to another environment will allow you to run the command without any restrictions.
That is the ticket. Thank you. Can you tell me what the 2>&1 does in this code?
 
It means that all output and errors are being forwarded (written) to the status.txt file. The 1 denotes standard output (stdout). The 2 denotes standard error (stderr).
 
Back
Top