Run the yum command in CentOS to install the crontab program of the scheduler.
Overview
With the "Task Scheduler", you can schedule any script, program, or document to run at a very convenient time. In general, it is to regularly execute a script or program.
Common usage
Timed Shutdown
Regular check for updates
Regularly back up system configurations, databases, and logs
Regular cleanup of junk files
Check whether the installation is complete.
# crontab-bash: crontab: command not found
Execute the crontab command. If command not found is reported, it indicates that the crontab is not installed.
Start Installation
# yum -y install vixie-cronLoaded plugins: fastestmirror, refresh-packagekit, securityExisting lock /var/run/yum.pid: another copy is running as pid 25960.Another app is currently holding the yum lock; waiting for it to exit...
The automatic upgrade is running, and yum is locked.
You can disable the yum process by force:
# Rm-f/var/run/yum. pid
Then you can use yum.
# yum -y install vixie-cronLoaded plugins: fastestmirror, refresh-packagekit, securityDetermining fastest mirrors * base: mirrors.btte.net * extras: mirrors.sina.cn * updates: mirrors.sina.cnbase | 3.7 kB 00:00 extras | 3.4 kB 00:00 extras/primary_db | 32 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 1.9 MB 00:07 Setting up Install ProcessResolving Dependencies--> Running transaction check---> Package cronie.x86_64 0:1.4.4-15.el6 will be installed--> Processing Dependency: dailyjobs for package: cronie-1.4.4-15.el6.x86_64--> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.4-15.el6.x86_64--> Running transaction check---> Package cronie-anacron.x86_64 0:1.4.4-15.el6 will be installed--> Processing Dependency: crontabs for package: cronie-anacron-1.4.4-15.el6.x86_64---> Package sendmail.x86_64 0:8.14.4-9.el6 will be installed--> Processing Dependency: procmail for package: sendmail-8.14.4-9.el6.x86_64--> Running transaction check---> Package crontabs.noarch 0:1.10-33.el6 will be installed---> Package procmail.x86_64 0:3.22-25.1.el6_5.1 will be installed--> Finished Dependency ResolutionDependencies Resolved=============================================================================================================================================================================================== Package Arch Version Repository Size===============================================================================================================================================================================================Installing: cronie x86_64 1.4.4-15.el6 base 74 kInstalling for dependencies: cronie-anacron x86_64 1.4.4-15.el6 base 31 k crontabs noarch 1.10-33.el6 base 10 k procmail x86_64 3.22-25.1.el6_5.1 base 162 k sendmail x86_64 8.14.4-9.el6 base 716 kTransaction Summary===============================================================================================================================================================================================Install 5 Package(s)Total download size: 994 kInstalled size: 2.1 MDownloading Packages:(1/5): cronie-1.4.4-15.el6.x86_64.rpm | 74 kB 00:00 (2/5): cronie-anacron-1.4.4-15.el6.x86_64.rpm | 31 kB 00:00 (3/5): crontabs-1.10-33.el6.noarch.rpm | 10 kB 00:00 (4/5): procmail-3.22-25.1.el6_5.1.x86_64.rpm | 162 kB 00:00 (5/5): sendmail-8.14.4-9.el6.x86_64.rpm | 716 kB 00:00 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Total 1.3 MB/s | 994 kB 00:00 Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning Transaction Installing : procmail-3.22-25.1.el6_5.1.x86_64 1/5 Installing : sendmail-8.14.4-9.el6.x86_64 2/5 Installing : cronie-1.4.4-15.el6.x86_64 3/5 Installing : crontabs-1.10-33.el6.noarch 4/5 Installing : cronie-anacron-1.4.4-15.el6.x86_64 5/5 ERROR:dbus.proxies:Introspect error on :1.2513:/org/freedesktop/PackageKit: dbus.exceptions.DBusException: org.freedesktop.DBus.Error.NoReply: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.Unable to send message to PackageKit Verifying : crontabs-1.10-33.el6.noarch 1/5 Verifying : cronie-anacron-1.4.4-15.el6.x86_64 2/5 Verifying : sendmail-8.14.4-9.el6.x86_64 3/5 Verifying : cronie-1.4.4-15.el6.x86_64 4/5 Verifying : procmail-3.22-25.1.el6_5.1.x86_64 5/5 Installed: cronie.x86_64 0:1.4.4-15.el6 Dependency Installed: cronie-anacron.x86_64 0:1.4.4-15.el6 crontabs.noarch 0:1.10-33.el6 procmail.x86_64 0:3.22-25.1.el6_5.1 sendmail.x86_64 0:8.14.4-9.el6 Complete!
View Command help
Crontab does not support options such as-h or-help, but you can still use it to view Command help
# Crontab-hcrontab: Invalid option -- hcrontab: usage error: unrecognized optionusage: crontab [-u user] file crontab [-u user] [-e |-l |-r] (default operation is replace, per 1003.2) -e (edit user's crontab)-l (list user's crontab)-r (delete user's crontab)-I (prompt before deleting user's crontab) -s (selinux context)
You can also use the info crontab command to view detailed help information.
The cron Service provides the crontab command to set the cron service. The following are some parameters and descriptions of this command:
Crontab-u // set a user's cron service. Generally, the root user needs this parameter when executing this command.
Crontab-l // list the details of a user's cron Service
Crontab-r // Delete the cron service of no user
Crontab-e // edit a user's cron Service
For example, to view your cron settings as root: crontab-u root-l
For another example, root wants to delete fred's cron settings: crontab-u fred-r
When editing the cron service, the edited content has some formats and conventions. Enter crontab-u root-e.
In the vi editing mode, the edited content must conform to the following format:/1* ** Ls>/tmp/ls.txt
Service Status Control
/Sbin/service crond start // start the service
/Sbin/service crond stop // close the service
/Sbin/service crond restart // restart the service
/Sbin/service crond reload // reload the configuration
/Sbin/service crond status // view the status
Or use
# service crond start
# service crond stop
# service crond restart
# service crond reload
# service crond status
Start
You can also enable the service automatically when the system starts:
Add:
/sbin/service crond start
Now the Cron Service is in the process and we can use it.