It is a good practice to schedule certain routine tasks to run automatically. For example, you may want to remove old core files once a week, summarize accounting data daily, and rotate system log files monthly. crond and crontab: Schedule Routine TasksUsing crontab, you can submit a list of commands in a format that can be read and executed by crond. Working as Superuser, you can put commands in one of the /etc/cron.* directories to be run at intervals specified by the directory name, such as cron.daily. When SELinux is set to use a targeted policy, it protects the cron daemon. You can disable this protection if necessary. For more information refer to "Setting the Targeted Policy with system-config-securitylevel" on page 402. Tip: cron stops for no one; try anacron The crond daemon assumes the system is always running. A similar utility, anacron, does not make that assumption and is well suited to portable and home computers that are frequently turned off. The anacron utility takes its instructions from the /etc/anacrontab file unless you specify otherwise. Refer to the anacron and anacrontab man pages for more information. at: Runs Occasional TasksLike the cron utility, at allows you to run a job sometime in the future. Unlike cron, at runs a job only once. For instance, you can schedule an at job that will reboot the system at 3 AM (when all users are probably logged off): # at 3am at> reboot at> CONTROL-D <EOT> job 1 at 2006-02-01 03:00 It is also possible to run an at job from within an at job. For instance, an at job might check for new patches every 18 days, something that would be more difficult with cron. kcron: Schedules TasksThe kcron utility provides a GUI to cron, allowing you to create and modify crontab files. Scheduling tasks with kcron is a matter of clicking buttons (Figure 16-3). Figure 16-3. The kcron Task SchedulerRun kcron when you are logged in as yourself to view and modify your personal crontab file. When you run kcron as root, you can modify any crontab file on the system. At first, kcron displays a window that lists Tasks and Variables, and, when you are running as root, Users. The Description column of this window is very wide and does not fit in the window. Use the right-left scrollbar to view its contents. If you are running as root, you need to double-click a user to display the Tasks folder. To create a new crontab entry, highlight Tasks, and select New from Edit on the menubar (or from the right-click menu). To modify an entry, highlight the entry, and select Modify from Edit on the menubar. In the resulting window, enter the name of the program you want to run in the Program text box, and click buttons or place check marks corresponding to the dates and times you want to run the program. Unless you redirect it, output from a program that cron runs is mailed to you. |