at command

source : tecadmin.

“at” command is one of the useful tool in console linux. It works as a timer to run a script/ apps. In my case, I always use it as an auto run apps to the certain time. Let’s say that I want to change some system setting remotely. But I don’t if the setting will work as a charm or crash. Meanwhile, I did the setting change remotely. So if the setting crashed, I can’t connect into the system. This is the ‘at’ will reverse the setting to the origin and I can connect into it again.

The syntax is quite easy.

at 07:00 // to run at specific time
at now + 1hour // to run one hour later
at now + 5min // to run 5 minute later
at 10:00 AM Sun // to run at 10 morning the nearest Sunday

I can make specific time just by adding ‘now + time’.

Here are another syntax.

atq // to list the task already made
atrm xx // to remove the task marks with job id (number)
at -c 5 // to see what the task number 5 (id)

Remember the ‘at’ command is one time scheduler only. If you need the recurring task, use ‘crontab’.

How to write a command after executing ‘at now + 5 minute’?

at>echo "my script will display this"
at> {press ctrl+d}

Always put an enter at the end of the script. After rows of script, put another enter at the last line, and press ctrl+d to save the scripts. It also means that the script will run immediately.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.