Worked all day to set up a cron task on Plesk.
To test cron tasks, I used this method and created two documents: my_cron.php and an empty my_cron.txt

Code my_cron.php :

 <?php $fd = fopen("my_cron.txt","a"); fwrite($fd, "Обращение к файлу - ".date("dmY H:i")."\r\n"); fclose($fd); ?> 

Then I went to the PleskWebsites & DomainsScheduled Tasks panel and added a task:

 2 * * * * wget -q -O /dev/null "http://site.com/testcron/my_cron.php" 

Unfortunately, the task does not start, please help to understand.

Linux debian server, permissions to txt and php files - 777.

Cron works, tested it by creating such a cron job:

 echo "Test email" 

Upd: found that when installing on the first domain (a total of 2 domains are used in plesk: one is located in the /site1.com/httpdocs directory, the second is located in the /site1.com/site.com directory) when my_cron.php file is uploaded /site1.com/httpdocs/my_cron.php and running the wget -q "http://site1.com/mycron.php" -O /dev/null command wget -q "http://site1.com/mycron.php" -O /dev/null everything works fine the only difference that occurs in ip addresses. When checking the usual request wget http://site1.com/my_cron.php , the ip address of the server goes out, when requesting wget http://site.com/my_cron.php , the external ip address goes out.

Upd2: after changes in the file / etc / hosts ping two domains via ssh shows the same ip. Both wget and curl queries work, but cron tasks do not run.

  • ru.stackoverflow.com/a/487530/191416 - try this. - don Rumata
  • @alexanderbarakin cron works for the command to send an email, for the command wget does not work - Darklez
  • @alexanderbarakin thanks, the full directory of the file my_cron.txt is: /var/www/vhosts/site.com/site2.com/testcron/my_cron.txt - Darklez
  • @alexanderbarakin to the request wget -O - http://site.com/testcron/my_cron.php Received the following response: --2016-03-08 11:26:07-- http://site.com/testcron/my_cron.php Resolving site.com (site.com)... ip.address.here Connecting to site.com (site.com)|ip.address.here|:80... connected. HTTP request sent, awaiting response... 404 Not Found 2016-03-08 11:26:07 ERROR 404: Not Found. --2016-03-08 11:26:07-- http://site.com/testcron/my_cron.php Resolving site.com (site.com)... ip.address.here Connecting to site.com (site.com)|ip.address.here|:80... connected. HTTP request sent, awaiting response... 404 Not Found 2016-03-08 11:26:07 ERROR 404: Not Found. - Darklez
  • @Darklez, ERROR 404: Not Found - so deal with this error, and not with the “task that doesn't come up” invented by you. - aleksandr barakin

1 answer 1

The solution is to add an additional domain and ip to the /etc/hosts