Nine, services and scheduled tasks

First, the service

For RHEL6:
1.linux system service into three types:
services controlled by the init
with a service system V start up scripts
managed by xinetd service
. 1> .init
/ etc / inittab
the service is configured in / etc / inittab profile
this servers can be configured respawn parameter that indicates the service will automatically restart each time you close when
2> .system V
storage path for the startup script /etc/rc.d/init.d/
/etc/rc.d/init.d/xxx STOP | Start | restart | Status
Service xxx STOP | Start | restart | Status
EG:

3> .xinetd
also known as super-server, often manage a variety of lightweight Internet services
/ etc / xinetd / xxx
Service Start xinetd

2.chkconfig command: service boot from the start
Usage:
chkconfig --list list all the list of services
chkconfig xxx on | off if the next boot from Kai
chkconfig --list display a list of services
chkconfig --level 35 xxx on | off designated run sectors

3.ntsysv Services Configuration tool
yum install -y ntsysv
ntsysv

RHEL7:
systemd Linux system is a tool used to manage systems and services. He was designed to be backward
compatible with SysV init script, and provides a number of functions. A parallel guidance system comprising at
start system services. Activated on demand daemon. Support system state snapshot, based on dependency
control logic of service. In RHEL7 in systemd replace upstart becomes the new default
initialization system.

1, start a service
Service name Start
systemctl Start name.service

2, stop a service
Service name STOP
systemctl STOP name.service

3, restart a service
Service name restart
systemctl restart name.service

4, only the service is running, try to restart him.
name condrestart Service
systemctl the try-restart name.service

5, reload the configuration file
Service name reload
systemctl reload name.service

6, check whether the service is running
Service name Status
systemctl Status name.service
systemctl IS-the Active name.service

7, displays the status of all services
Service --status-All
systemctl List-Service Units --type --all


Second, scheduled tasks


1, a one-time scheduled tasks
at the trigger
atd daemon

1> View existing one-off scheduled tasks
at -l, atq

2> delete the existing one-off scheduled tasks
atrm task number

3> Disposable scheduled tasks access control
/etc/at.allow allow
/etc/at.deny reject
a user per line, check at.allow file
generally only the root user can do one-off scheduled tasks

2, periodic scheduled tasks
1> .cron Scheduled Tasks allows users to "schedule" automatic cycle to complete certain tasks task
crontab -e -u
crontab the -l to view the schedule
crontab -r targeted deleted


2> Turn on service crond
Service crond Start
chkconfig crond ON

3>. Edit the crontab
the crontab -e -u the root
daily 23:58 empty / tmp / all content
* * * * *
time-moon and peripheral commands
58 23 * * * rm -rf / tmp / *
week 3 , 17:05 open ftp service
0 17 * * 1,3,5 service vsftpd start
every three days 1-10 point between 18 to perform a restart http service
0 18 1-10 / 3 1 * service httpd restart
January - March at 23 o'clock every three days to restart the httpd service
* 23 * 1-3 / 3 * service httpd restart

All files (/ var / ftp / pub) 23:00 emptied weekly 1,3,5 ftp root directory of the
* 23 * * 1,3,5 rw -rf / var / ftp / pub

3, tmpwatch empty the old file to the specified directory
eg: tmpwatch / tmp / *

 

Guess you like

Origin www.cnblogs.com/xmdjb/p/10949412.html