Linux Task Scheduler cron chkconfig Tools SYSTEMD Management Services Unit Introduction Target Introduction

Source: Internet
Author: User
Tags openssh server

[[email protected] ~]# crontab-e writing a task plan
No crontab for root-using an empty one

1 echo "OK" >/root/cron.log on January 29 (Monday) 11:20 execution: echo "OK" >/root/cron.log

The command crontab-e actually opens the/var/spool/cron/username file (/var/spool/cron/root is turned on if the user is root). Open this file using the VIM Editor, save command mode input: Wq.

[[email protected] ~]# Crontab-l view the Scheduled Tasks
1 echo "OK" >/root/cron.log

[[email protected] ~]# crontab-r Delete task plan, use with caution. It will delete all the plans at once. If you want to delete only one plan, you can use the-e option to enter crontab for editing.
[Email protected] ~]# crontab-l
No crontab for Root

(1) Clear/var/log/slow.log This file every 1:20 A.M.

1 * * * echo "" >/var/log/slow.log

(2)/bin/sh/usr/local/sbin/backup.sh executed every Sunday 3 o'clock.

0 3 * * 0/bin/sh/usr/local/sbin/backup.sh

(3) 14th 4:10 every month to execute/bin/sh/usr/local/sbin/backup_month.sh.

10 4 14 * *, bin/sh/usr/local/sbin/backup_month.sh

(4) Perform ntpdate time.windows.com every 8 hours

* */8 * * * * ntpdate time.windows.com

(5) Execute/bin/sh/usr/local/sbin/test.sh at 1, 12, 18 o ' Day.

0 1,12,18 * * */bin/sh/usr/local/sbin/test.sh

(6) Perform/bin/sh/usr/local/sbin/test2.sh from 9 to 18 daily.

0 9-18 * * */bin/sh/usr/local/sbin/test2.sh

Check to see if the Crond service has been started, see active, if the boot status is active (runing), inacvtive (dead) is not started.

[Email protected] ~]# ls/etc/init.d/
Functions Netconsole Network README

[[email protected] ~]# chkconfig network off network
[Email protected] ~]# chkconfig--list

Note: This output shows only the SysV service and does not contain the native SYSTEMD service. SysV configuration data may be overwritten by native SYSTEMD configuration.
If you would like to list the SYSTEMD service, please do ' systemctl list-unit-files '.
To view services enabled for a specific target, perform
' Systemctl list-dependencies [target] '.

Netconsole 0: Off 1: Off 2: Off 3: Off 4: off 5: off 6: Off
Network 0: Off 1: Off 2: Off 3: Off 4: off 5: off 6: Off

[Email protected] ~]# Chkconfig Network on
[Email protected] ~]# chkconfig--list

Note: This output shows only the SysV service and does not contain the native SYSTEMD service. SysV configuration data may be overwritten by native SYSTEMD configuration.
If you would like to list the SYSTEMD service, please do ' systemctl list-unit-files '.
To view services enabled for a specific target, perform
' Systemctl list-dependencies [target] '.

Netconsole 0: Off 1: Off 2: Off 3: Off 4: off 5: off 6: Off
Network 0: Off 1: Off 2: Open 3: Open 4: Open 5: Open 6: Off

[Email protected] ~]# chkconfig--level 345 Network on
[Email protected] ~]# chkconfig--list

Note: This output shows only the SysV service and does not contain the native SYSTEMD service. SysV configuration data may be overwritten by native SYSTEMD configuration.
If you would like to list the SYSTEMD service, please do ' systemctl list-unit-files '.
To view services enabled for a specific target, perform
' Systemctl list-dependencies [target] '.

Netconsole 0: Off 1: Off 2: Off 3: Off 4: off 5: off 6: Off
Network 0: Off 1: Off 2: Open 3: Open 4: Open 5: Open 6: Off

[Email protected] init.d]# Chkconfig--del 123
[Email protected] init.d]# chkconfig--list

Note: This output shows only the SysV service and does not contain the native SYSTEMD service. SysV configuration data may be overwritten by native SYSTEMD configuration.
If you would like to list the SYSTEMD service, please do ' systemctl list-unit-files '.
To view services enabled for a specific target, perform
' Systemctl list-dependencies [target] '.

Netconsole 0: Off 1: Off 2: Off 3: Off 4: off 5: off 6: Off
Network 0: Off 1: Off 2: Open 3: Open 4: Open 5: Open 6: Off

[[email protected] init.d]# systemctl enable Crond.service
[[email protected] init.d]# Systemctl Disable Crond
rm '/etc/systemd/system/multi-user.target.wants/crond.service '
[[email protected] Init.d ]# systemctl enable Crond.service
ln-s '/usr/lib/systemd/system/crond.service '/etc/systemd/system/ Multi-user.target.wants/crond.service '
[[email protected] init.d]# systemctl status Crond.service
Crond.service-command Scheduler
loaded:loaded (/usr/lib/systemd/system/crond.service; enabled)
Active: Active (running) since day 2018-01-28 18:18:32 CST; 2h 48min ago
Main pid:861 (crond)
CGroup:/system.slice/crond.service
└─861/usr/sbin/crond-n

January 18:18:32 lizhipenglinux01 systemd[1]: Started Command Scheduler.
January 18:18:32 lizhipenglinux01 crond[861]: (CRON) INFO (Random_delay'll be scaled with factor 34% if used.)
January 18:18:32 lizhipenglinux01 crond[861]: (CRON) INFO (running with inotify support)
January 19:07:55 lizhipenglinux01 systemd[1]: Started Command Scheduler.

[Email protected] init.d]# systemctl disable Crond
RM '/etc/systemd/system/multi-user.target.wants/crond.service '

[Email protected] init.d]# Systemctl is-enabled Crond
Disabled

[Email protected] init.d]# Systemctl enable Crond
Ln-s '/usr/lib/systemd/system/crond.service '/etc/systemd/system/multi-user.target.wants/crond.service '

Soft links

[[email protected] system]# systemctl list-units-all--state=inactive list all status inactive units

[Email protected] system]# Systemctl list-units-all--type=service

[Email protected] system]# Systemctl is-active crond.service
Active

[Email protected] system]# Systemctl is-enabled crond.service
Enabled

[[email protected] system]# systemctl list-unit-files--type=target list all target in the system

[Email protected] system]# Systemctl Get-default
Multi-user.target

[Email protected] system]# Cat/usr/lib/systemd/system/sshd.service
[Unit]
Description=openssh Server Daemon
After=network.target Sshd-keygen.service
Wants=sshd-keygen.service

[Service]
Environmentfile=/etc/sysconfig/sshd
Execstart=/usr/sbin/sshd-d $OPTIONS
Execreload=/bin/kill-hup $MAINPID
Killmode=process
Restart=on-failure
Restartsec=42s

[Install]
Wantedby=multi-user.target

[Email protected] system]# Cat/usr/lib/systemd/system/crond.service
[Unit]
Description=command Scheduler
After=auditd.service Systemd-user-sessions.service Time-sync.target

[Service]
Environmentfile=/etc/sysconfig/crond
Execstart=/usr/sbin/crond-n $CRONDARGS
Execreload=/bin/kill-hup $MAINPID
Killmode=process

[Install]
Wantedby=multi-user.target

Linux Task Scheduler cron chkconfig Tools SYSTEMD Management Services Unit Introduction Target Introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.