cron is used with scheduling jobs for these execution servers. They are most often used in the automation or maintenance of system management. However, they are also relevant for the development of advanced Internet applications. There are many situations in which a web application may need to perform certain periodic tasks. Today we’ll look at cron job requirements.


Start by familiarizing yourself with the terms to understand this topic.

“Cron” is a time-based job role scheduler in Unix-like freebsd, operations (linux, Mac, etc.). Or it runs what are called tasks, “cron jobs”.

There is a very “cron daemon” running their websites on. A daemon is a strategy that constantly runs in the background and is usually initiated by an installation. This cron daemon is used to reliably run jobs in cron, respectively.According to your schedule.

Schedule is on a configuration screen called “crontab”. All these tasks and their timers are always listed there.

Why Use Cron Jobs?

Why is cron not working?

Servers have been using Cron Live jobs for quite some time now. However, since the target audience for this article is web oriented, let’s take a look at a few examples of cron jobs relevant to this area:

  • If you now have a membership site where accounts have expiration dates, you can take the time to have cron jobs periodically disable or remove expired accounts.
  • You can send daily newsletters via email. you
  • If your database has data pivot rooms (or materialized views), you can refresh them periodically using the job cron. For example, you can also display each visited website in a pivot table, others can contain summaries of daily traffic.
  • You can also remove cached yes y at certain intervals.
  • You can automatically check the content of your website for traffic interruptions and receive a regular report by email.
  • You can schedule long quests to run from a command line script instead of via a web script. For example, encode video captures or send bulk emails. do
  • You can even do something that simple, even if your latest tweets are stored in a text archive*.
  • Syntax

    10 * * 3 . /usr/bin/php /www/virtual/username/cron.php 2>&1

    1. The first > part of /dev/null is “10 * * *” -.Here we plan the timer type.
    2. The rest of the web is a command, as if it were being run from the command line.
    1. “/usr/bin/php”. PHP software packages, as a general rule, cannot be executed by individuals. So we need to run it through the PHP parser again.
    2. “/www/virtual/username/cron.php”. Often this is simply the path to the real scenario.
    3. “> /dev/null 2>&1”. This applies to parts of the output of the script. More on this later. This is

    Sync Syntax

    How do I run a .cron file?

    This is definitely the first part of the cron workstation chain mentioned above. It determines how often and until what minute the cron job runs.

    1. minute
    2. hour
    3. day month
    4. month
    5. Day and week


    It’s quite common to see an asterisk instead of a (*) number. This represents all the digits available for that position. For example, an asterisk in the position of minutes on the neck means that every minute passes.

    We need to go through a few stories to fully understand the syntax.


    * (space) * * * [command]

    This cron job runs almost the day before every hour (i.e. an hourly cron job):

    0 * * * [command]

    How do you know if Crond is running?

    This will probably also be an hourly cron job that will run at 21 minutes (i.e. at 00:15, 1:15, and 2:15. d.):

    15*5. * [command]

    30*2*2. [command]

    This Is* runs once a month, on the second day of the month (i.e. at midnight, i.e. 00:00 on January 2nd 00:00, February 2nd, etc.) :< /p>

    0 * 2 * [command]

    This could potentially be run on Mondays in blocks of 60 minutes (i.e. 24 times on * Monday alone):

    0 * 7 . one [can command]

    You can use multiple commas separated by sorting. This should run three times per hour, par 0 and minutes 10 20:

    0,10,20 * * * [command]

    The division operator is also used. .It .works .12 .intervals .at .hours, .every .5 .1 .. minutes:

    */5 * * * [command]

    In many cases, a hyphen can be used to indicate a range. This runs once per minute from 05:00 to 10:00:

    0 5-10 5 . * * [command]

    There is also an important special keyword that allows the client to run a cron job every day after the server is restarted:

    @reboot [command]

    Setting Up Admin And Cron Tasks

    There are several reliable ways to create and manage cron jobs.

    Control Panels

    How do you know if Crond is running?

    Many hosting websites offer referral control panels to their customers. If you are one of them, you can find a section in your control panel to manage your own cron jobs.

    Edit crontab

    Running this command will launch vi (text editor) and will no doubt allow you to view the contents of our crontab-e

    Then edit:

    crontab, it would be wise to familiarize yourself with the basic commands because vi is a little different from any other text editor you may have worked with.

    If you just want to see some of the existing crontabs without them, you can run this command to change your company:

    crontab -l

    crontab -p

    You can upload the file

    You put all your cron jobs in one statement and then put your crontab in there:

    crontab cron.txt

    Attention! This can alert without overwriting any existing cron job containing this content.


    # This cron job is doing something important
    10 very * * * * /usr/bin/php /www/virtual/username/cron.php > /dev/null 2>&1

    I have set an email address

    As mentioned, cron files are emailed by default, unless you delete them or redirect them to a file. The mailto parameter allows you to set or even change the email address to which they should be sent to user@example:

    mailto=”name. that com”
    # a cron job can be something very important
    10 * * 3. * /usr/bin/php /www/virtual/username/cron.php > /dev/null 2>&1

    Use Future Human Analyzer

    Cgi-php scripts are written as executable files by default, but PHP scripts are not. They need to be executed through the PHP parser, so we need to add the path in the parser before the corresponding script path.

    * * * 3 * . [path /usr/bin/php to PHP script]

    Why is cron not working?

    Sometimes it can be found elsewhere in “/usr/local/bin/php”, for example: To find out, you can try running this in the control line:

    what php

    Output Control

    If the cron script’s output is not currently being processed, it will email it to the user of your bank account on the server.

    Delete output

    If you set “>/dev/null At 2>&1” to make the cron command (or any other non-command) work, the output is simply ignored.

    A closing bracket (>) is used to redirect output. For example, par “/dev/null” is like a black hole for output. Anything that goes there is ignored in the system.Part

    This causes “2>&1” to failDirects specific STDERR output (error) to STDOUT output (normal). This also occurs in most “/dev/null”.

    Output to file

    Review the output of cron in the file containing the closing brace (>) to avoid errors:

    10 (blank) * * /usr/bin/php * /www/virtual/username/cron.php > /var/log/cron.log

    This will each overwrite times the output file. If you really want to append the output to the general end of the file, rather than rewriting it entirely, use the double square bracket (>>) instead:

    How do I run a .cron file?

    How do I enable Cron on Windows 10?