{"id":1360,"date":"2024-06-12T00:01:47","date_gmt":"2024-06-12T00:01:47","guid":{"rendered":"http:\/\/shijuvarghese.com\/?p=1360"},"modified":"2025-05-24T04:06:49","modified_gmt":"2025-05-24T04:06:49","slug":"at-command-running-one-time-future-task","status":"publish","type":"post","link":"http:\/\/shijuvarghese.com\/?p=1360","title":{"rendered":"AT command : Running one time future task"},"content":{"rendered":"<p>Unlike the the cron job is mainly used to schedule repetitive tasks, the &#8220;<strong>at<\/strong>&#8221; command is used to run a command just once, but schedule at a later time.<\/p>\n<p>That yum package to be installed is\u00a0<strong>at<\/strong><\/p>\n<p><strong>[root@centos9vm ~]#<\/strong> dnf install at -y<\/p>\n<p><strong>[root@centos9vm ~]#<\/strong> systemctl start atd<br \/>\n<strong>[root@centos9vm ~]#<\/strong> systemctl enable atd<\/p>\n<p>The below command created a file 1 min from now<\/p>\n<p><strong>[root@centos9vm ~]#<\/strong> at now +1min<br \/>\nwarning: commands will be executed using \/bin\/sh<br \/>\nat&gt; touch \/root\/sam1.txt<br \/>\nat&gt; &lt;EOT&gt;<br \/>\njob 9 at Wed Jun 12 06:08:00 2024<\/p>\n<p><strong>[root@centos9vm ~]#<\/strong> atq<br \/>\n9 Wed Jun 12 06:08:00 2024 a root<\/p>\n<p><strong>[root@centos9vm ~]#<\/strong> ls -l | grep sam1<br \/>\n<strong>[root@centos9vm ~]#<\/strong> ls -l | grep sam1<br \/>\n-rw-r&#8211;r&#8211;. 1 root root 0 Jun 12 06:08 sam1.txt<\/p>\n<p>The same command can be executed in another method<\/p>\n<p><strong>[root@centos9vm ~]#<\/strong> echo &#8220;touch \/root\/sam2.txt&#8221; | at now +1min<br \/>\nwarning: commands will be executed using \/bin\/sh<br \/>\njob 12 at Wed Jun 12 06:12:00 2024<br \/>\n<strong>[root@centos9vm ~]#<\/strong> atq<br \/>\n12 Wed Jun 12 06:12:00 2024 a root<\/p>\n<p><strong>[root@centos9vm ~]#<\/strong> ls -l | grep sam2<br \/>\n<strong>[root@centos9vm ~]#<\/strong> date<br \/>\nWed Jun 12 06:12:01 AM IST 2024<br \/>\n<strong>[root@centos9vm ~]#<\/strong> ls -l | grep sam2<br \/>\n-rw-r&#8211;r&#8211;. 1 root root 0 Jun 12 06:12 sam2.txt<\/p>\n<p>=== ===<\/p>\n<p>The common commands used are as follows:<\/p>\n<ul>\n<li>at now +1min<\/li>\n<li>at noon<\/li>\n<li>at midnight<\/li>\n<li>at 13:30<\/li>\n<li>at 14:30 2027-9-25<\/li>\n<\/ul>\n<p>Command to see the at commands yet to run is as follows:<\/p>\n<p><strong>[root@centos9vm ~]#<\/strong> atq<br \/>\n14 Wed Jun 12 06:19:00 2024 a root<\/p>\n<p>This information is also available in\u00a0<strong>\/var\/spool\/at<\/strong> along with the commands associated<\/p>\n<p>== === =<\/p>\n<p>Command to see details of a job in queue<\/p>\n<p><strong>[root@centos9vm ~]#<\/strong> at -c 14<\/p>\n<p>Command to remove a job in queue<br \/>\n<strong>[root@centos9vm ~]#<\/strong> atrm 14<br \/>\n[root@centos9vm ~]# atq<br \/>\n[root@centos9vm ~]#<\/p>\n<p>We can deny list of users from executing jobs using\u00a0&#8220;at&#8221; command. The names if these users needs to be listed in<\/p>\n<ul>\n<li>\/etc\/at.deny<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Unlike the the cron job is mainly used to schedule repetitive tasks, the &#8220;at&#8221; command is used to run a command just once, but schedule <a class=\"mh-excerpt-more\" href=\"http:\/\/shijuvarghese.com\/?p=1360\" title=\"AT command : Running one time future task\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":1791,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,31,30],"tags":[],"class_list":["post-1360","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-rhel-4","category-rhel-9"],"_links":{"self":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/1360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1360"}],"version-history":[{"count":7,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/1360\/revisions"}],"predecessor-version":[{"id":1368,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/posts\/1360\/revisions\/1368"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=\/wp\/v2\/media\/1791"}],"wp:attachment":[{"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1360"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shijuvarghese.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}