Cron is one of the useful utilities that you will find in Unix operating system. It allows you to schedule commands at a specific time. These scheduled commands are known as Cron Jobs. In this article, you’ll learn how to create a cron job and understanding the common commands to run a cron job via your Hosting Manager.
But first we’ll help you better understand the commands ro run a cron job.
What Are the Commands to Run a Cron Job
The command contains two parts:
[program to execute (perl/pyth./php)] [switches] [script]
The program to run will specify the type of script you are running and will either be:
- Perl/CGI Scripts (should be in cgi-bin with permission 755)
The script will need to be set on the direct path where it is located on our server, for example: /home/username/public_html/path/to/script, with username being your username.
Run a PHP script:
php -q /home/username/public_html/scripts/testrun.php
Run a Python script:
Run a Perl/CGI scripts:
Understanding the User Agent String
We have disabled the wget command for security purposes. You can run most scripts that require wget with the lynx or curl command. The latest update of mod_security and php updates will prevent lynx and curl from working if a user agent is not set.
Below is the command to set the user agent:
curl --user-agent YOUR_STRING (URL)
lynx -dump -useragent=YOUR_STRING (URL)
Now that we’ve established few of the commands. Let’s learn how to create a cron job. Continue reading this article to learn how.
How to Create a Cron Job
Follow the steps below to create a cron job.
||Access your Hosting Manager.
||Scroll down to the Advanced tab, then click on the Cron Jobs option.
||Under Add New Cron Job, select Common Settings from the drop-down list.
||Set the following details to schedule your command:
||Enter a number from 0-59.
||Enter a number from 0-23.
||Enter a number from 1-31.
||Enter a number from 1-12 or the first three letters of the month, example, Jan
||Enter a number from 0-7 or the first three letters of the weekday, example, Mon..
||Under Command, specify the command to run then click Add New Cron Job button.
Congratulations! You just successfully created and run a cron job. If you need any further assistance or if you have any questions in setting up a cron job, please let us know. We’d love to help!
Fantastic...Thank you for your feedback =)
Sorry... Please submit a support ticket or try another search.