Need an expert to help you with
" How to run a Cron Job" ?
" How to run a Cron Job" ?
How to run a Cron JobcPanel’s Cron Job functionality can be used to execute Unix commands or even to automate the execution of your PHP, Python, or Perl scripts. You can also specify which email address you would like the Cron daemon to send the job’s results to.
How to get to the Cron Job Page in cPanelUse the next steps to go to the Cron job page in cPanel: Step 1: Begin by entering cPanel. Step 2: Scroll down until you see the ‘Advanced’ area. Step 3: Click on ‘Cron jobs’ and you should be brought to the ‘Cron Jobs’ page.
Setting up the Email NotificationYour Cron Job can let you know through email each time it runs, just type in the email address you want to use in the email field before clicking on the ‘Update Emai’l button. If you are not interested in notifications, then you will have to redirect the command’s output as such below.
mycommand >/dev/null 2>&1Instead of ‘mycommand’, put in your own command. Set up a New Cron job Now tell Cron job when to run. This is the order:
[minute] [hour] [day] [month] [weekday] [command] 41 04 * * * /my/script –vThis should execute each morning at 4:41 AM. What ‘*’ means is that every day/month, etc, for example; 41 04 * * * = every 41 minutes of each 4th hour of every day of every weekday of the month. Weekday is every day of the week and as well as the weekends. Note that many customers thought that weekdays are just Monday – Friday, instead of interpreting it as Monday – Sunday. Whenever you set the time, you might also want to set cron to execute at an odd minute, rather than 12:00 or 12:30 of the hour. In the example we have shown, Cron Job will run at 4:41. This is because that a lot of people set their Crons to execute at either the top or bottom of the hour. If everybody, execute their crons at the same time, they might run slower and maybe even slow the overall server down for regular website traffic. If cron is set at an odd time, this guarantees the better performance of the script. Specify the command to run The command has two parts.
[program to execute (perl/pyth./php)] [switches] [script]The program to run will specify which type of script you will be running and will be one of the two following.
- To run a PHP script: php -q /home/usern5/public_html/scripts/testrun.php
- For Python scripts: python /home/usern5/public_html/path/to/script
- For Perl/CGI scripts: /home/usern5/public_html/cgi-bin/yourscript.pl
Using the User Agent StringThe ‘wget’ command is not enabled on any shared servers for security purposes. A lot of scripts that run with the ‘wget’ command are useable with the ‘lynx’ or ‘curl’ command. The new ‘mod_security’ rules that were applied with the latest php updates should stop lynx and curl from working if a user agent is not set. To set a user agent, you just need to use the following command.
curl --user-agent YOUR_STRING (URL) lynx -dump -useragent=YOUR_STRING (URL)The full Cron Job command will look like the below.
/usr/bin/curl --user-agent cPanel-Cron http://example.com/cron.phpKeep in mind that you can change ‘cPanel-Cron’ to anything you would like it to be.
Updated on 04 Feb 2018
Add a comment