skip to Main Content

I’m trying to run a test script using crontab within Plesk. The php file simply emails me a message

mail('[email protected]','Cron Test','Test');  

My path to php is /user/bin/php

I have entered * in every field, to run the script every minute with the following command:

/usr/bin/php -q /usr/httpdocs/crontest.php

However, the script is not being run.

Can anyone help?

I’m probably missing something simple, I’ve never used cron before.

Any advice appreciated.

Thanks.

3

Answers


  1. I would start by getting it to write to a log file. eg:

    * * * * * /usr/bin/php -q /usr/httpdocs/crontest.php >> /a-location/crontest.log 2>&1
    

    This will at least give you any obvious errors like not being able to find php etc.

    Login or Signup to reply.
  2. I found that when using the user based cron in plesk, there are a number of issues:

    first I found that you should reference the script from the virtual domain. If your script has an absolute address of /var/www/vhosts/domain.com/httpdocs/email-this.php, you should reference it as httpdocs/email-this.php in the crontab.

    Second, the script has to have very particular permissions, but not sure what they “must be.” apache:apache is all that ever worked for me. Even with the group write permission set, user still had to be apache… weird.

    Third, the easiest way to do the testing was to edit the crontab directly instead of going back into plesk every time I needed to make a change… Edit your crontab like this:

    crontab -u [filesystem-username] -e

    Fourth, I could never get the crontab to write to a log file outside of httpdocs (I tried statistics/logs/cron_log every way I could think of… lol… no dice). I ended up just adding the MAILTO directive at the top of the crontab file during testing:

    eg:

    [email protected]
    ##      *       *       *       *       *       php -q httpdocs/cron.php
    
    Login or Signup to reply.
  3. Also see this if you have Plesk 10 or above: http://shaun.net/2011/09/solving-plesk-10-3-1-cron-issues/

    I had to do this

    /usr/local/psa/bin/server_pref -u -crontab-secure-shell “/bin/sh”

    to get this (example) working: wget -O – http://www.yourdomain.com/cron.php

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search