失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > linux未被识别crond服务 linux 定时任务 crond 服务介绍

linux未被识别crond服务 linux 定时任务 crond 服务介绍

时间:2019-10-02 13:35:09

相关推荐

linux未被识别crond服务 linux 定时任务 crond 服务介绍

linux定时任务crond服务应用指南

Linux的定时任务crond(crontab)服务

1、crond是什么?

crond是linux系统中用来定期执行命令或者指定程序的程序(软件)

2、秒级任务

(1)crond需要方式实现

(2)自己写守护进程shell循环

(3)Quartz也可实现妙计任务

3、定时任务的作用

服务器:7*24小时开机提供服务是网站的基本特征

有重要数据:提高备份周期和备份数量

Linux的定时任务分类

linux系统中定时任务调度的工作可以分为一下两种

(1)系统自身的定期执行的任务

系统周期性自行执行的任务工作。如轮询系统日志、备份系统数据、清理系统缓存等

[root@ysolin ~]# ls -l /var/log/messages* 系统的日志

-rw-------. 1 root root 23 6月 28 14:44 /var/log/messages

-rw-------. 1 root root 96 6月 26 03:49 /var/log/messages-0626

系统自动轮询任务的设置配置路径:

[root@ysolin ~]# ls -l /etc/ |grep cron

-rw-------. 1 root root 541 11月 23 anacrontab

drwxr-xr-x. 2 root root 4096 6月 24 18:13 cron.d

drwxr-xr-x. 2 root root 4096 9月 27 cron.daily

-rw-------. 1 root root 0 11月 23 cron.deny

drwxr-xr-x. 2 root root 4096 9月 27 cron.hourly

drwxr-xr-x. 2 root root 4096 9月 27 cron.monthly

-rw-r--r--. 1 root root 457 9月 27 crontab

drwxr-xr-x. 2 root root 4096 9月 27 cron.weekly

(2)用户执行的定时任务

某个用户或系统管理员定期要做的任务工作,用户执行放入任务工作,也就是我们运维管理人员执行的任务工作。

例如:服务器时间同步

[root@ysolin ~]# crontab -l #查看定时任务

time sync by solin

*/5 * * * * /sbin/ntpdate >/dev/null 2>&1

2、Linux系统下定时任务软件种类

(1)at适合执行一次就结束的调度任务。依赖服务atd

(2)anacron适合于非7*24小时开机的服务准备。anacron并不能指定具体时间执行任务工作,而是以天为周期或者在系统每次开机后执行的任务工作,它会检测服务器停机期间应该执行,但没有执行的任务工作,并将该任务执行一遍。

(3)crond,crond服务默认情况(每分钟),会检查系统中是否有需要执行的定时任务,若有会根据定义好的规则来执行这个定时任务。

注:

(1)crond服务是运行的程序,而crontab命令用户用来设置定时规则的命令

(2)crond服务是企业生产工作中常用的重要服务,at和anacron很少使用,可以忽略。

定时任务crond使用说明

1、语法指令

crontab [-u user] {-l | -e | -r |-i}

查看帮助

[root@ysolin ~]# crontab --help

crontab: invalid option -- '-'

crontab: usage error: unrecognized option

usage: 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)

2、指令说明

通过crontab我们可以在固定的间隔时间执行指定的系统指令或script脚本。时间间隔的单位是分、时、日、月、周及以上的任意组合。

3、使用者权限文件

文件 说明

/etc/cron.deny #该文件中所列用户不允许使用crontab命令

/etc/cron.allow #该文件中所列用户允许使用crontab命令,优先于/etc/cron.deny

/etc/spool/cron/ #所有用户crontab配置文件默认都存在此目录,文件名以用户名命令

注:

crontab -e = vi /var/spool/cron/root

crontab -l = cat /var/spool/cron/root

4、指令选项说明含义表

-e (edit user's crontab) #编辑crontab文件内容

如果觉得《linux未被识别crond服务 linux 定时任务 crond 服务介绍》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。