Persevering with together with his Linux 101 sequence, Jack Wallen introduces you to the fundamentals of activity scheduling with cron.

Picture: Pixabay

For the admins who’re new to Linux, I need to introduce you to the cron instrument. What’s cron? Merely said, cron means that you can create scheduled jobs on a Linux system. Say, as an illustration, you’ve got a backup script, known as You have positioned that script in /usr/native/bin, so it may be executed globally and also you need to be certain the backup occurs at both a particular time of day or recurrently on a sure day of the week. 

How do you do that? You invoke cron. 

To make use of this, you add conjobs to your consumer’s crontab file. Go surfing to your Linux server and concern the command:  

crontab -l

This may checklist out all current cron jobs. To create a brand new cron job, you edit the crontab file. To do that, concern the command: 

crontab -e

You’d then add a line on the backside of that file to schedule the working of your backup script. Here is the place it will get a bit difficult. The primary part of the road is the place you declare when the job is to run. Originally of that line there are 5 slots for time, that are (from left to proper): Minutes (0-59), hours (0-23), day of month (1-31), month (1-12), day of week (0-6, though you should utilize Sunday, Monday, Tuesday, and many others., and Sunday could be represented by 0, 7, or Sunday). 

For example you need that backup job to run each Sunday at 11pm. That entry may very well be 0 23 * * 0. A star signifies the job is to occur each iteration. On this case we have indicated the job ought to occur Sunday at 11pm, each week and each month. The remainder of this line would come with the specific path to the executable, so /usr/native/bin/ 

Our complete line could be 0 23 * * 0 /usr/native/bin/ Save the crontab file with the Ctrl+X mixture (if nano is your editor of alternative), and the job is scheduled. You may need to be certain your job is listed with the crontab -l command. 

Congratulations, you have simply scheduled your first cron job. This needs to be simply sufficient to get you going with this highly effective Linux scheduling instrument.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the most recent tech recommendation for enterprise professionals from Jack Wallen.

Additionally see

Source link