Setting up scheduled tasks or ‘cron’ jobs in Plesk is an incredibly useful feature. I’ve typically used scheduled tasks for MySQL database backups, automatic email notifications and twitter feed caching.
After a bit of scrabbling around various internet forums and threads, I worked out that a couple of steps were needed to get a PHP scheduled task working on a Linux dedicated/VPS server using the Plesk control panel.
Before you start however, double check that your PHP script works by running it direct from a browser.
From the main ‘Websites & Domains tab’, select FTP Access and the main system user. Make sure the drop down option ‘Access to the server over SSH’ is changed from ‘forbidden’ to /bin/bash’. Enabling access to the server over SSH allows remote shell services to be executed, such as a wget command which we’ll use next. If this option is not selected, you might get an error similar to -: /usr/bin/wget: No such file or directory
From ‘Websites & Domains’, select ‘scheduled tasks’ followed by the same system user we gave server access for in step 1. Select ‘schedule new task’ and enter the scheduled settings similar to the below, substituting site.com and script.php with the full path to your PHP script.
I’ve found it more straightforward to use wget – a utility to download files from the Internet – rather than the PHP utility as PHP sometimes involves modifying the PHP script itself.
If you want to have the scheduled task run at a specific time, enter the hour/day/month etc as a numeric value. Using ‘*’ means ‘all’ and using ‘*/’ sets an interval, so the above schedule will be set to run at 10 minute intervals every hour, every day of the week.
This will be summarised in the scheduled tasks page as below:
/usr/bin/wget is the server path to wget and -O /dev/null tells wget to discard the contents of the file rather than the default behaviour of trying to save the file.
You can check the script works by selecting ‘settings’ and entering your email. Hopefully, you’ll get an email with the wget status that looks something like the below:
–2013-03-28 17:00:01– http://www.site.com/script.php
Resolving www.site.com… 123.456.789.123
Connecting to www.site.com|123.456.789.123|:80… connected.
HTTP request sent, awaiting response… 200 OK
Saving to: `/dev/null’
0K ………. ………. ………. ………. ………. 873M
50K ………. ………. ………. 1.08G=0s
2013-03-28 17:00:02 (951 MB/s) – `/dev/null’ saved 
Scheduling a custom php script URL with plesk »
Hi Tom, I too have had a couple of fruitless, wasted days trying to figure this out. Your post was very helpful – I’m almost there but I was wondering if you could clarify something for me? I’m trying to copy a file from one location to another. The following code results in success all the way to ‘sampleresult.txt: Permission denied’:
/usr/bin/wget ‘http://domain.com/folderone/sampleresult.txt” “http://domain.com/foldertwo/sample.txt”
However, your code results in success all the way:
/usr/bin/wget -O /dev/null “http://domain.com/foldertwo/sample.txt”
But I don’t know how to get the successfully downloaded ‘null’ data into a usable file… Any light you can shed would be much appreciated.
Thanks again for your very handy post.
Looks like this page is the only one which mentions the SSH thing. I’ve been looking for this for hours, literally. Thanks a lot!
I love you. I LOVE you! Thanks.
thank you very much, you saved my life
Thank you very much Mr. Tom Elliott.
I have been searching about scheduled task but couldn’t find the correct “Command”.
Its really a good article. You have mentioned every point very well.
Thanks Once again.
The SSH info under FTP settings sorted my issue out.Thought I was beginning to go crazy 🙂
Thanks very much
After days of searching all over the internet and even in the official Plesk forums, I couldn’t find a solution to this problem and now -thanks to you- I have finally got it sorted! Thank you so much Tom! If it weren’t for you, my laptop would’ve been in pieces in the garden. 😀