“The script runs and after 3 seconds it errors out, but it does not output anything to the log file so I am unable to know which is the cause.”
And in the comments you state you are checking the log in your cron job command located here:
/var/www/vhosts/website-here/logs/topfbk.logIf your command is this:
/usr/bin/php httpdocs/sources/australia.php >> /var/www/vhosts/website-here/logs/topfbk.logThen if the script is failing it will never be able to append output to /var/www/vhosts/website-here/logs/topfbk.log.
The only way you can really debug this is to check the actual PHP command line error log; not a log you have arbitrarily created. By default the PHP command line interface does not log errors to a log file. I explain how to establish a PHP command line error log file here in this Stack Overflow post. It’s not that complicated and valuable to do in a case like this.
But past any of this, is that httpdocs/sources/australia.php the true full path to your script? When the cron job runs, are you sure it is running within a directory where that path is valid?
I would recommend running that command manually from the command line with the full path to the script like this:
/usr/bin/php /full/path/to/httpdocs/sources/australia.phpJust replace /full/path/to/ with the actual full path and see if that works. If it works, then the lack of a full path is the problem. If it doesn’t work, establishing the PHP command line error log will shed clues on what else might be happening in your code.
- cPanel
- Plesk
Some scripts/applications require certain scripts to be run at a certain time to function properly. On Windows servers, you can set them up to run at certain times by creating a scheduled task (which is similar to running cron
jobs on Linux servers).
Different versions of Plesk may have slightly different appearances, but the steps, buttons, and icons are the same.
Creating a Scheduled Task in Plesk:
You can set up Scheduled Tasks in Plesk by doing the following:
1) Log in to Plesk.
2) Click on Scheduled Tasks in the upper right corner.
3) Click on the Add Task button.
4) Determine the appropriate type:
- Run a command - Specify the full path to the executable file to be run. This includes binary files, shell scripts, and batch files.
- Fetch a URL - Send a request (cURL) to a specific URL.
- Run a PHP script - Specify the path to the script relative to your virtual host directory. PHP
version can be specified.
5) Set/frequency-time task should run
6) Add a Description of the task. (Optional)
7) Select notification preference
8) Click OK to schedule the task or click Run Now to schedule the task and immediately run it
Removing a Scheduled Task in Plesk
- Log in to Plesk.
- Click on Scheduled Tasks in the upper right corner.
- Select the name of the task that you would like to remove.
- Click on the Remove button.
- It will load a new page and ask if you really want to delete it. Check the Confirm Removal box and click on the OK button.
- You will be taken back to the Scheduled Tasks screen, and it should say: "Information: Scheduled tasks were removed."
Notes
The user you are logging in with should have enough permissions to create a scheduled task. Windows Shared customers automatically have permission, and the Admin user for Windows Dedicated Servers automatically has permission. Additional users created by the Admin on a Windows Dedicated Server may or may not have permission to set up scheduled tasks, depending on what permissions you give them.
General help
Cron Job From Plesk for Moodle
- ◄ Moodle course completion Status
- Retrieve quiz attempt ►
Hi
I am using moodle 3.11.5+ version and I want to see the cron job schedule task thru plesk web edition.
in the schedule task i hv set the script path (run a php script) to /var/www/vhosts/example.com/httpdocs/moodle/moodle/admin/cli/ and argument as cron:run
cron style as *****
when i click run now, it run without error but moodle log shows no script runs. However if i use the remote access version it runs perfectly fine.
please advise how to schedule on plesk
Regards
Rudraksh
I don't run Plesk, but ... in what you've shared ... Why do you have 2 moodle directories in the path? /moodle/moodle/ ... maybe only one /moodle/ The other ... in moodlecode/admin/cli/ there are several .php scripts that will run only from command line. So in your cron setup, end it with a pointer to the php script the runs the cron ... thusly .../cli/cron.php 'SoS', Ken
- ◄ Moodle course completion Status
- Retrieve quiz attempt ►