当前位置: 首页 > article >正文

单一执行和循环执行的例行性工作

单一执行的例行性工作:只执行一次就结束

1.1at命令的工作过程


 /etc/at.allow,写在该文件的人可以使用at命令
 /etc/at.deny,黑名单
 两个文件如果都不存在,只有root能使用

[root@localhost ~]# systemctl status atd
[root@localhost ~]# ll /var/spool/at
[root@localhost ~]# ll /var/log/cron

1.2 at命令详解

#定义三分钟之后显示hello
[root@server ~]# at now + 3 minutes

2、循环执行的例行性工作

循环执行的例行性工作:每隔一定的周期就需要执行一次

2.1 crontab

/etc/cron.allow,写在该文件的人可以使用crontab命令
/etc/cron.deny,黑名单
两个文件如果都不存在,只有root能使用

[root@localhost ~]# systemctl status crond
[root@localhost ~]# ll /var/log/cron
[root@localhost ~]# ll /var/spool/cron/

2.2 crontab命令

[root@localhost zhuo]# crontab --help
crontab: invalid option --'-'
crontab: usage error: unrecognized option
Usage:
 crontab [options] file
 crontab [options]
 crontab -n [hostname]

Options:
 -u <user>  define user
 -e         edit user's crontab
 -l         list user's crontab
 -r         delete user's crontab
 -i         prompt before deleting
 -n <host>  set host in cluster to run users' crontabs
 -c         get host in cluster to run users' crontabs
 -T <file>  test a crontab file syntax
 -s         selinux context
 -V         print version and exit
 -x <mask>  enable debugging

Default operation is replace, per 1003.2

2.3 系统的计划任务

[root@localhost ~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# For details see man 4 crontabs
# Example of job definition:
# .---------------- minute (0 - 59)
# | .------------- hour (0 - 23)
# | | .---------- day of month (1 - 31)
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR
sun,mon,tue,wed,thu,fri,sat
# | | | | |
# * * * * * user-name command to be executed

当需要同一时间执行多个脚本时,可以将这多个脚本放在一个目录下,然后使用run-parts来执
行。
run-parts:该命令可将后面接的“目录”内的所有文件找出来执行。 
 


http://www.kler.cn/news/353898.html

相关文章:

  • 【C++11】可变模板参数详解
  • Python RabbitMQ 入门 pika
  • Java之集合介绍
  • 在移动设备上扫描登机牌条形码,有哪些挑战 ?
  • 2010年国赛高教杯数学建模C题输油管的布置解题全过程文档及程序
  • 【C语言】自定义类型:联合和枚举
  • 【算法】约瑟夫环问题
  • vue使用js-xlsx导入本地excle表格数据,回显在页面上
  • 本地群晖NAS安装phpMyAdmin管理MySQ数据库实战指南
  • 深度解析LMS(Least Mean Squares)算法
  • 单链表的定义
  • 多进程思维导图
  • 在ArcGISPro中使用 SAR 数据和深度学习绘制洪水地图
  • Android GPIO方式解码红外数据
  • LeetCode讲解篇之2320. 统计放置房子的方式数
  • 学习Redisson实现分布式锁
  • 【Linux系统编程】环境基础开发工具使用
  • ⭐ Unity Pico PXR_SDK转场淡入淡出
  • kimi帮我解决ubuntu下软链接文件夹权限不够的问题
  • 基础数据结构——用递归完成冒泡排序