linux计划任务-aws

atd

单次计划任务:atd

语法:

atd 时间
服务:atd 开启状态
启动:systemctl restart atd
开机自启:systemctl enable atd

举例

举例1(小时和分钟来执行):

[root@ip-9-0-1-235 hdlefs]# at 16:15
at> echo "hello word!" > /var/www/html/hello.html
at> <EOT>
job 1 at Tue Jun 21 16:15:00 2022

举例2(年月份-小时分钟来执行):

[root@ip-9-0-1-235 html]# at 16:18 2022-6-21
at> echo "hello word 1!" >> /var/www/html/hello.html
at> <EOT>
job 2 at Tue Jun 21 16:18:00 2022
[root@ip-9-0-1-235 html]# cat hello.html
hello word!
hello word 1!

举例3(当前时间+多少时间来执行):

[root@ip-9-0-1-235 html]# at now +10min
at> echo "hello word 2!" >> /var/www/html/hello.html
at> <EOT>
job 3 at Tue Jun 21 16:32:00 2022

命令

查看系统中有多少计划任务:at -l
计划任务存放的目录:ll /var/spool/at/
删除计划任务:atrm 编号(at -l即可查看编号)

周期性计划任务:

配置文件:vim /etc/crontab
查看状态:systemctl status crond
启动服务:ystemctl restart crond
开机自启:systemctl enable crond

/etc/crontab文件解析:

*	*	*	*	*	command
分	时	日	月	星	命令

crond存放的命令和脚本在
/etc/cron.d/
/etc/cron.daily/ 每天
/etc/cron.deny
/etc/cron.hourly/ 每小时
/etc/cron.monthly/ 每月d
/etc/cron.weekly/ 每周

针对用户级别的计划任务:
对于root用户:
命令:
crontab -e 创建一个计划任务
crontab -l 显示
crontab -r 删除计划任务

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值