use of at on linux

本文深入解析Linux at 命令的基本用法,包括如何指定执行命令的时间、时间格式规范以及常见选项如查看待执行任务、删除任务等。同时介绍了at命令的交互式操作方式及时间格式的多种表达形式。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

'at' is a quite use shell command on linux.

It can help you to execute a command at some time or some timer later.


We use 'man at', we will get a long helping list, which maybe a litte confusing for the new learner.

Here is the basic usage format of 'at'


1 useage

a. at time -f comman.sh

for example

 at 21:03 -f a.sh
job 6 at Mon Sep 19 21:03:00 2011

after your input you will get the prompt, and you can let a.sh be executed at indicated above.

b. at time command

remember , this is an interactive command, which means you need more than more times interactive input for this usage

for example

$ at 21:02 (input enter)
at> touch 2102(input your command and enter)
at> <EOT>(use ctrl+d to quit and save)
job 5 at Sun Sep 18 21:02:00 2011


2 time format

in the example we use the time 21:02, which is a human comprehensive format hour:minute, of course , there will be more formats as showed below:

a. hh:mm MMDDYY

which means hour:minute MonthDayYear

for example:

$ at 20:22 112023 -f a.sh
job 10 at Mon Nov 20 20:22:00 2023

and you can use other format

b. now+  timeInterval

for example

$ at now + 2 minute -f a.sh
warning: commands will be executed using /bin/sh
job 11 at Sun Sep 18 21:21:00 2011

of course the timeInterval can be more than "minute" such as hour/day/month/year

what's more, it doesn't if there is a space between '+2minute' or not, which can be '+ 2 minute' or '+2 minute' or '+ 2minute'.


3 other option of at

a. at -l

see all the pending of the current user.

same as 'atq'

b. at -d jobid

delete the job specified by the job id which can be seen with 'at -l'

same as 'atrm'

c. at -c jobid

see the  content of the job.


other examples:

at 5pm + 3 days /bin/ls

at 5pm + 2 weeks /bin/ls

at 17:20 tomorrow /bin/date

at 23:59 12/31/1999 echo the end of world !


4 complementarity

format out put of date

"date +%Y%m%h%M"

you will the the fomated string of the date, which will be very useful if you want to create a date named file.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值