Helps fix computer errors

Here, a slash is used in combination with ranges to indicate the values ​​provided x location.

0-55/5 * * * * means that the human command will be executed every five minutes (0, 5, 15, 10, …, 55).

  • cron format

  • Structure generated by crontab entries
  • Tips for learning Cron

  • Personnel, repetition and delivery
  • Another scam: “@” syntax
  • Notes and warnings
  • cygwin – which method to set up cron
  • crontab Syntax

    How do I remove a cron job from a crontab?

    You can use the crontab influence to view, add, remove, or configure cron jobs with the following option: crontab -e Edit the crontab file on the computer, or create it if the item does not already exist. crontab -l Displays the contents of the crontab file. crontab -r Deletes the current crontab file. crontab -i – Delete your regular crontab file using the command line long before you delete it.

    Users often ask what do you see, crontab arguments and how to create them… copy or by others who were aware of the secret secret of the old Unix lore :-)… No mystery Here, however, will be a brief introduction. .


    List, entries

    First, it’s probably easiest to create a my.cron (or similar) file with entries, and then use the command

    % crontab my.cron

    present them. BUT this is NOT recommended if you are running in a multi-user environment as the above command will often replace the current user’s cron job with the contents of the my.cron file. ALWAYS do everything first, then

    % crontab -l >my.cron

    How do I skip a number of values in a cron job?

    Added forward slash (/) to ignore specified number in values. For example, “*/4” in a person’s time field indicates “every 4 hours”, i.e. 0, multiple, 8, 12, 16, 20. A member must be specified in this file to direct cron jobs if the file exists . .

    which lists all existing entries and redirects to its own my.cron file, edits and modifies, not to mention reloads.
    Please note that

    % crontab -e

    also this causes cron synonyms to be edited… BUT it assumes that the EDITOR environment variable is set (if none else is set, the default editor will probably be used as vi).

    Authorization fields and format

    The structure of the entries themselves is as follows – if I wanted to run my favorite “Hello World” every minute and add it to one file, I would do:

    #.- Possibility (0 – 59)
    #|Â .- Lesson (0 – 23)Â
    #|Â |Â .- Ceremony of the month (1 – 31)Â
    #|In |In | .- Month (1–12) OR January, February, March, April…
    #|In |In | | . – Day of the week (0 7) – (Sunday=0 or maybe 7)
    #Â Â Â Â Â |Â OR Sun, Mon, Tue, Wed, Thu, Fri, Sat
    #|In |In | | | .- command
    #|In |In | | |Â |
    # My hello world example does this – almost every protocol is developed
    * * * matches “Hello World” >>/home/jlauret/cron.log

    Please note that above I have given all the fields and their meaning. In this case, the output is redirected to a log file.nala /home/jlauret/cron.log.
    Lines marked with “#” are comments. Make it a habit to leave an explanation section just before each cron entry to say what it does – all of these can help you (or others if you’re using the same admin repository or group account).

    cron Tips

    Although the nature of the crontab syntax is not well described in the man pages (a little unknown, especially in the Linux man pages), my man pages will give you great information about everything else. So, a male visit


    Interestingly, Linux cron accepts variable=value at the beginning of cron. For example, you can add something like

    to the first lines of the crontab document.


    and this method will execute all the commands executed in the crontab entries to go under “sh” AND bypass anything you may have as a shell defined in the account. Another useful variable is MAILTO (if MAILTO doesn’t work, try MAIL as it varies slightly depending on the version of our own cron service).

    Please send any errors or possibly (undirected log) output to Note that if you are NOT redirecting the output to a full file, the default behavior is definitely to redirect the results to as usual on a local account. Be sure to clear STDOUT and STDERR. In my simple example above, only the actual standard output was redirected to /home/jlauret/cron.log. You can edit this redirect to your liking

    *something* * 3 . * echo "Hello world" >>&/home/jlauret/cron.log


    Range, Consistency, Or Steps

    The following syntax is usually available on Linux (note that it may not seem valid, especially on older operating systems and cron-related versions)

    * * * * * 1-5 equals "Hello World" 

    work from Monday to Friday. The hyphen “-” turned out to be a range of values ​​in this statement. Similarly, the forward slash “/” indicates a step or repetition of all N. For example:

    */2 * * 6 . * echo "Hello world"
    0 0-23/2 * ( space ) * echo "Hello World"

    meaningno, you do this at midnight and then every two hours (range and repetition are combined here, of course, you can limit yourself to only night time). You can also specify a default format that should work with ANY version of cron):

    0 together with 0,2,4,6,8,10,12 * * * means "Hello World"

    to repeat the recording for two hours from 0 (midnight) to 12 (noon) people. Trace combinations are also possible on Linux, i.e. H Your company can specify fields 0-6, 20-23 (in your own example, this would work for the hour field). Again, this probably won’t work with ATT and BSD (old) crons. So if you want to write standard cron entries, beware of overly fancy syntax, whereas if you mostly work with Linux, you really should be ashamed of not needing their convenience.

    Another Thing Is The “@” Syntax

    What is the best way to schedule a cron job?

    Cron is generally best for scheduling recurring runs. Scheduled special tasks can be created using the appropriate at utility. activities are controlled when the crontab file (cron table), the key configuration file that defines shell requirements, runs regularly on a schedule.

    There are special keywords that take cron into account, and it looks like they turn into the “@” character. They are listed below

    @reboot: run at the same time after reboot.
    @yearly: second run of the year, i.e. “0 nothing 1 1*”.
    @annually: quickly shows the year, i.e.e. “0 9 1 1 *”.
    @monthly: run once a month, so “0 zero 1 * *”.
    @weekly: runs once a week, so “0 9 * * 0”.
    @daily: run once a day, so “0 0 * – *”.
    @hourly: runs once per second, so “0 * * 1 . *”.

    # Manage various
    @monthly /home/jlauret/bin/monthly maintenance

    # Wipe free space from C drive right after a month
    @monthly a /home/jlauret/bin/wipe -s c

    # Delete junk files terminated by editors weekly
    @weekly /bin/rm -f /cygdrive/c/Users/jlauret/.saves-*

    Messages in this case take the form of the @CMD tag. Again, don’t expect people to run the cron version sometimes. But you had the ability to use these tags on Linux to perform certain repetitive tasks. @reboot means that the command will only run once after the computer is rebooted (this can be handy to make sure the service is started on every reboot). Name=”Notes”> < br>

    Notes And Warnings

  • Remember that when a cron entry is in progress, NO SHELL is executed in full (i.e. your awesome .cshrc or .bashrc is not necessarily completely original), so you shouldn’t use a full rewriteConnection value for the command line. Especially if you’re using a better script (Perl or other annotations), which means your normal shell environment variables probably won’t be available in your Perl script.