RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Writing and Automating PHP Crons in Windows and Linux : Page 2

Find out how to automate PHP scripts so they run unattended at scheduled times on both Windows and Linux.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Scheduling Crons with cPanel
The graphical web-based control panel cPanel (see Figure 1) lets you manage your domain through a web interface. Using cPanel you can manage all aspects of mail, crontab tasks, backup, FTP accounts, CGI scripts or web site statistics, and many other tasks. Among those is "Cron Jobs," an automated process that runs tasks at predefined date and time intervals on your web server (see Figure 2). As examples, you can create cron jobs to delete temporary files every month to save disk space, or to copy a MySQL database to a separate location as a backup once each week.

Figure 1. cPanel Main Page: cPanel is a tool that lets you manage various tasks, including cron jobs, using a graphical web interface.
Figure 2. cPanel Cron Jobs: You can opt to use either the Standard or Advanced (Unix Style) "experience level;" Standard is recommended.

Figure 3. Standard Cron Job Screen: Specify the output location, the job you want to run, and select the time and frequency of your job.
There are two ways to create a cron job using cPanel: Standard, and Advanced (Unix style). Create a Standard Cron Job
The Standard method lets you configure the time and frequency of your job. This is the simplest method and is recommended.

You'll see the Standard Cron Manager screen (see Figure 3). To create a Standard cron job, follow these steps:

  • Enter the email address where you want the output of your cron job files to be sent.
  • The first option in the "Entry 1" panel is "Command to run." Enter the command or path to a script/file that you want the cron job to run.
  • Next, set the time and frequency of your cron job using the five time/date-related fields shown in Figure 3.
  • When you're done, click the Commit Changes button to create the cron job entry, or click the Reset Changes button to undo your modifications.
  • You'll see a confirmation page showing a "Cron Updated!" message. Click on the Go Back button to return to the main Cron Job screen.
Figure 4. Advanced Mode: The figure shows the screen where you configure the time and frequency of your job using Advanced mode.
Create an Advanced Cron Job
The Advanced (Unix Style) method (see Figure 4) lets you enter the time parameters in Unix style.

  • Enter the email address if you want to receive confirmation emails after the job executes.
  • Configure the time and frequency of the job and enter the cron command or path to the script/file you want the cron job to run.
  • Click Commit Changes to create the cron job entry or click Reset Changes button to undo your modifications.
  • A confirmation page will appear showing the "Cron Updated!" message. Click on the Go Back button to return to the main Cron Job screen.
Both the Standard and Advanced methods create cron jobs, but the advanced interface is closer to the Unix command-line way of creating a job.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date