Linux系统使用at/crontab指令的操作方法
时间:2022-04-07 22:03:52
熟悉电脑的用户都了解,Linux系统中at命令可以定时执行,而crontab命令则是循环执行的,所以这两个命令都可以控制程序运行的时间。那么,如何设置呢?下面小编就来介绍一下Linux系统如何使用at/crontab指令?
Linux系统
要执行 at 指令,只要 at 时间,按下 enter ,再输入要执行的命令,结束时按下 ctrl+d 就可以排定一个 at 的排程。
at 的时间格式可以用 1 个数字(指定小时)、2 个数字(指定小时)、 4 个数字(指定时和分),时和分中间也可以用 : 分隔,如 03:45,另外可以在数字之后加上 am, pm 指定上下午,否则 at 会把时间视为 24小时制, 如 05:25pm。在 POSIX 中,有另外指几个特别的时间:
时间-time
时间的数字範围为 [00,59]。
midnight = 12:00 am (00:00)
noon = 12:00 pm
now = 指定执行 at 的时间
日期-date
年份所使用的数字是公元,一定是4 个数字。
指定月份和星期时,所使用的 word 决定于 LC_TIME 环境变数中所列的”月份”和”星期”名称或是其缩写。
日期要符合所指定的月份。
today = 今天
tomorrow = 明天
增加量-increment
可使用 minutes, hours, days, weeks, months, 或 years 等字,在使用时,以 + 号开头。
利用 at 指令所执行的命令,所使用的环境变数、工作目录、档案建立的 mask 等等变数,在真正执行排定的命令时,这些变数要和执行 at 指令时相同。
at 执行权限控制档案:
/usr/lib/cron/at.allow
/usr/lib/cron/at.deny
范例:
at 6pm
at moon
at today
at 02:00am
at 18:00
at 18:00
at 6pm today + 1 week 等同于 at 6pm today next week
at 6pm Jan 2 , 2005
at 6pm mon
at now
at 所要执行命令的时间过了的话,会等到下一次这个时间点出现的时候再执行,例如指定在今晚 6:00 执行,而现在是 7:00 的话,指令会在明天晚上 6:00 才执行。
要删除某个己排定的工作,使用 at -r at-job-id
在 gentoo 下,预设是没有 at 这个程式的,要先执行以下指令安装才行:
emerge -av at
/etc/init.d/atd start
而指令的 timespec 放在 /usr/share/doc/at-XX.XX/timespec.gz 说明档中。
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
dw cc 2019如何自定义键盘快捷键
excel如何套用乘法公式
Win10系统怎么关闭腾讯游戏进程teniodl.exe?
![](https://img.aspxhome.com/file/2023/26/a225692_0s.jpg)
Excel数据录入有哪些技巧 Excel简单录入数据教程
![](https://img.aspxhome.com/file/2023/0/a143370_0s.png)
Win10系统怎么禁止应用访问任务?Win10系统禁止应用访问任务的方法
![](https://img.aspxhome.com/file/2023/0/52780_0s.png)
哪些操作会影响固态硬盘寿命?
![](https://img.aspxhome.com/file/2023/2/a285204_0s.jpg)
7 个表格函数技巧,让你少做 80% 重复工作
![](https://img.aspxhome.com/file/2023/3/a157253_0s.gif)
win10系统怎么开启远程桌面?
![](https://img.aspxhome.com/file/2023/1/a277478_0s.png)
Win10系统怎么关闭屏保?
![](https://img.aspxhome.com/file/2023/4/49084_0s.jpg)
绝地求生如何显示fps?绝地求生fps显示方法
![](https://img.aspxhome.com/file/2023/3/a295402_0s.jpg)
wps文档如何自动分栏
![](https://img.aspxhome.com/file/2023/1/a182701_0s.png)
微软Win10 Office预览版应用更新下载
![](https://img.aspxhome.com/file/2023/0/15580_0s.jpg)
微软最新Win11 KB5015814(22000.795)更新补丁来啦!(附更新内容)
![](https://img.aspxhome.com/file/2023/1/a271869_0s.jpg)
excel如何根据表格字数的数量进行排列?
![](https://img.aspxhome.com/file/2023/1/40291_0s.jpg)
电脑版WPS演示文稿怎么为图表添加线性预测
![](https://img.aspxhome.com/file/2023/3/a183233_0s.png)
Excel中进行VBA函数继续复制表格的操作技巧
win7笔记本wifi共享网络设置教程(供手机上网)
![](https://img.aspxhome.com/file/2023/29/a257790_0s.jpg)
win10系统电脑安装卡巴斯基后qq可以上但网页打不开的解决方法
![](https://img.aspxhome.com/file/2023/28/a242065_0s.jpg)
电脑运行慢怎么办? 提升电脑速度的方法
win7电脑取消共享文件夹的方法?
![](https://img.aspxhome.com/file/2023/3/a294809_0s.jpg)