From 22299f84d39c26dd661a217809ae3174ccfaf4eb Mon Sep 17 00:00:00 2001 From: Luke Smith Date: Mon, 5 Jul 2021 09:33:36 -0400 Subject: spell form --- cron.html | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'cron.html') diff --git a/cron.html b/cron.html index f2eb449..2206ffa 100644 --- a/cron.html +++ b/cron.html @@ -19,13 +19,13 @@

You can schedule anything! Some examples of what you might have done already include:

Some tasks that you might want to schedule may include:

And many more, anything you can do can be turned into a cronjob. @@ -34,25 +34,25 @@

Basic Cronjobs

- This the preferred method for personal tasks and scripts, it's also the easiest to get started with. Run the command crontab -e to access your users crontab + This the preferred method for personal tasks and scripts; it's also the easiest to get started with. Run the command crontab -e to access your user's crontab

- Once you have figured out the command you want to run you need to figure out how often you want to run it and when. I am going to schedule my system updates once a week on at 3:30 AM on a Monday. + Once you have figured out the command you want to run you need to figure out how often you want to run it and when. I am going to schedule my system updates once a week on at 3:30 AM on Mondays.

We now have to convert this time (Every Monday at 3:30 AM) into a cron time. Cron uses a simple but effective way of scheduling when to run things.

- Crontab expressions look like this * * * * * command-to-run + Crontab expressions look like this * * * * * command-to-run The five elements before the command tell when the command is supposed to be run automatically.

So for our Monday at 3:30AM job we would do the following:

-

 .---------------- minute (0 - 59)
+            
.---------------- minute (0 - 59)
  | .------------- hour (0 - 23)
  | | .---------- day of month (1 - 31)
- | | | .------- month (1 - 12
+ | | | .------- month (1 - 12)
  | | | | .---- day of week (0 - 6)
  | | | | |
  * * * * *
@@ -67,7 +67,9 @@
 
             

More examples

- Let's add another job, our backup job (for the purposes of this our backup command is just called backup) We want to run backup Every evening at 11PM, once we work out the timings for this we can add the to the same file as the above by running crontab -e This would mean our full crontab would look like this: + Let's add another job, our backup job (for the purposes of this our backup command is just called backup). + We want to run backup every evening at 11PM. + Once we work out the timings for this we can add the to the same file as the above by running crontab -e This would mean our full crontab would look like this:

0 23 * * * backup

Consecutive times

@@ -87,21 +89,18 @@

We can also randomly specify non-consecutive arguments with a comma. Suppose you have a script you want to run at the midday of the 1st, 15th, and 20th day of every month. - You can specify that my putting 1,15,20 for the day of the month argument: + You can specify that by putting 1,15,20 for the day of the month argument:

0 12 1,15,20 * * /usr/bin/pay_bills_script

"Every X minutes/days/months"

-

We can also easily run a command very several minutes or months, without specifying the specific times: -

+

We can also easily run a command every several minutes or months, without specifying the specific times:

*/15 * * * * updatedb
-

- This cronjob will run the updatedb command every 15 minutes. -

+

This cronjob will run the updatedb command every 15 minutes.

Beware of this Rookie Mistake Though...

@@ -146,13 +145,14 @@

- Run the command ls /etc/cron* you should see a list of directories and there contents. The directories should be something like the below + Run the command ls /etc/cron* you should see a list of directories and there contents. The directories should be something like the below: +

    -
  • /etc/cron.d This is a crontab like the ones that you create with crontab -e
  • -
  • /etc/cron.hourly
  • -
  • /etc/cron.daily
  • -
  • /etc/cron.weekly
  • -
  • /etc/cron.monthly
  • +
  • /etc/cron.d This is a crontab like the ones that you create with crontab -e
  • +
  • /etc/cron.hourly
  • +
  • /etc/cron.daily
  • +
  • /etc/cron.weekly
  • +
  • /etc/cron.monthly

-- cgit v1.2.3