The at and cron Commands

Thus far we have only touched on commands that will allow you to automate processes, because automation is the easiest way to get things done. If you know how to automate something, then it's as simple as setting up the job one time and having it run on a schedule. In this section of the lesson, we will talk about how the at and cron commands can help you automate tasks in Unix. There is a great deal to talk about when considering backups and running complex processes with these commands, and we cannot dig into these topics in-depth in a book of this nature. For now, be aware that these commands are powerful and there is much more to learn about them. You may want to dig into this subject a bit deeper if you continue to work with Unix.

So, when considering backups in particular but any process overall, Unix users may need to schedule jobs with the at and cron commands. Let's look at how this can be done.

Hey You—Back Up! Backups are a part of life when you want to make sure that your data (files and directories) are recoverable in case you delete something or make a mistake.

Unix is not forgiving, so if you do make a mistake, your only recourse is to get a copy of the missing or deleted data. You would get this copy from a backup source, most likely a tape backup system if you are at work. If you are at home, just about any media device can be used for backup. Remember, backups are important, because if you ever need a copy of your data, backups ensure that the copy is there.


There are two basic ways to set up your Unix system to run a command (process) at a specific time; one way is to use the cron command, and the other is to use the at command. Your Unix system will most likely always have the cron process running, but in many cases, if this command is not needed, it will be disabled by your Unix system administrator. (For security reasons, it is common in most environments to always terminate, disable, and remove anything from a system that its users don't need to do their work. If you are running Unix at home for fun, then you may have just about everything running on your system if you are logged in as root or a SuperUser.) In any case, cron (if enabled) will allow you to automate complex jobs such as log rotations, backups, cleanup commands, and so on. The cron command will do this on a continuous schedule that you configure. cron enables you to run commands in intervals as small as one second or as long as one year.

You should also know what a crontab is, because this term will most certainly come up when you work with a Unixor Linux-based operating system. You can create a personal crontab file that holds information about the interval on which you want a command to run. You can then use the crontab <filename> command to add your request to the system's crontab file. With some Unix versions, you can use crontab -e to bring up your currently set crontab entries directly into an editor as well.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.133.206