While cron jobs can help you automate tasks on your server, they can sometimes fail. Here are some of the most common reasons and how to fix them:
Before creating a cron job, it is recommended to test your script to make sure it works properly, regardless of its automatic scheduling. To do this, you can open the file in a web browser (by typing in the script file's URL) or execute it via SSH, depending on the type of script you have. If your script throws an error message or otherwise does not work, check the code. You may need to seek help from a developer if you are unable to resolve the issue.
Please note that an empty output does not necessarily mean that a cron job is not working. Most scripts do not have a default output, so you may need to add it manually.
Incorrect Path or URL
Double-check that the file is located on the path or URL you are using to set up your cron job. At Hostinger, all file paths start at /home/. For example, if you want to execute a file script.php located in the public_html folder of your domain, the full path will look similar to one of these:
You can verify your path structure in the FTP Accounts section.
If the Cron Job is configured to open a file via URL rather than a path to a file, you can use the
curl command via the terminal to test if it works:
curl -v 'https://domain.tld/path/to/script.php'
Replacing the URL with your URL, path, and file name.
Use of Special Characters
Creating PHP cron jobs on hPanel does not support special characters such as ">/dev/null 2>&1". If your cron job requires special characters, you will need to create create a .sh file and set up a custom cron job for executing it. Just follow this guide: How to set up a Cron Job with special characters at Hostinger.