• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Urban Penguin

The Urban Penguin - Linux Training

  • Home
  • About
  • Live Online Courses
  • Shop
  • RHCSA Guide
  • Programming
    • Master Editing Text Files Using VIM
    • Learn Shell Scripting with BASH
    • PERL Scripting in Linux
    • Ruby Scripting in Linux
    • Scripting with PowerShell
    • Learn C Programming using Linux and the Raspberry Pi
    • General Java Tutorials
    • Java 7 OCA Exam 1ZO-803
  • OS Tutorials
    • Red Hat and CentOS Training
      • Red Hat Enterprise Linux System Administration 1 – RH124
      • RHCSA – System Admin 2 – RH134
      • RHCE – EX294 – Automation With Ansible
    • Learning Ubuntu
    • LPI Training
      • LPI Linux Essentials
      • LPIC-1 Linux Administrator
      • LPIC-2 Certified Linux Engineer
      • LPIC-3 Senior Level Certification
        • LPIC-3 Exam 300 : Mixed Environments
        • LPIC-3 Exam 303 : Security
        • LPIC-3 Exam 304 : Virtualization and High Availability
    • Linux Technologies
      • Apache HTTPD Server
      • Learning PHP
      • Learning PUPPET
      • Learning SAMBA
      • Linux File-Systems
      • Monitoring with Nagios Core
      • MYSQL
      • openLDAP Directories on Linux
You are here: Home / Linux / RH134 / Scheduling Tasks with at

Scheduling Tasks with at

December 20, 2019 by The Urban Penguin

RHCSA 8 Study Guide

Scheduling Tasks with at is one way we can defer user jobs. In Red Hat Enterprise Linux 8 we can defer jobs to run at later times using cron, systemd or at, in this blog and video we look at scheduling tasks with at.

Not all scheduled jobs in Linux need to run regularly. Regularly occurring jobs can be run using systemd timers or crond. For deferred user jobs that often need to be run at a single time we have the atd service and the at command. For any job to run via the atd service, the service must be running. We can check the status of the service with the status sub-command from systemctl but don’t forget we can also check the service is enabled and active independently:

Instructor Led Online Courses

# systemctl is-active atd
active
# systemctl is-enabled atd
enabled

When creating scheduled tasks with the at command we need to define when it will run, we can specify the complete date or time just some parts of it, for example, to run the command date at 13:57 tomorrow we simply use:

# at 13:57 tomorrow
warning: commands will be executed using /bin/sh
at> date > /home/tux/date-file
at> <EOT>
job 1 at Fri Nov 29 13:57:00 2019

To exit the interactive command we use CTRL+D. To run a job at 05:00 on the next 27th December we can use the following format, noting that we can run multiple commands at any data and time specified:

# at 05:00 27 Dec
warning: commands will be executed using /bin/sh
at> ls /etc
at> du -sh /etc
at> <EOT>
job 2 at Fri Dec 27 05:00:00 2019

To list jobs we can use atq and atrm to remove jobs:

# atq
1 Fri Nov 29 13:57:00 2019 a root
2 Fri Dec 27 05:00:00 2019 a root
# atrm 1 2
# atq

There are many formats that we can use to specify when jobs should run, the following show a few examples:

$ at now +1 hour
warning: commands will be executed using /bin/sh
at> tar -czf $HOME/scripts.tgz $HOME/bin
at> <EOT>
job 2 at Wed Dec 11 20:14:00 2019

$ at teatime tomorrow
warning: commands will be executed using /bin/sh
at> find $HOME/ -type f -name "*.txt" -delete
at> <EOT>
job 3 at Thu Dec 12 16:00:00 2019

$ at 9 am 25 December 2020 
warning: commands will be executed using /bin/sh
at> wall "Happy Christmas"
at> <EOT>
job 4 at Fri Dec 25 09:00:00 2020

The time reference teatime is 4pm, how quaint! The now +1 hour style is quite useful, if the backup is going to take a while we can schedule it to happen as we leave work. We know that the backup will be ready for us the next day and we have not had to spend a lot of time thinking of formatting the date and time.

To list the contents of an at job we can use the option at -c and the job number.

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Reddit (Opens in new window)
  • Click to share on Pinterest (Opens in new window)
  • Click to share on Tumblr (Opens in new window)
  • Click to print (Opens in new window)

Filed Under: RH134

Primary Sidebar

Newest Video

The Urban Penguin On Youtube

Products

  • Complete RHCSA 8 Study Guide Complete RHCSA 8 Study Guide £5.99
  • SELinux Guide SELinux Fundamentals in Red Hat Enterprise Linux 8 £1.99
  • Managing POSIX ACLS in Linux £0.99
  • Managing Linux File Permissions £0.99
  • Kernel Module Administration in Linux £0.99

Categories

Pages

  • About The Urban Penguin
  • Contact Us
  • Shop
    • Basket
    • Checkout
    • My Account
  • LPI Training from The Urban Penguin
    • Live and Pluralsight hosted courses
    • Complete Linux Essentials
    • LPIC-3 Senior Level Certification
      • LPIC-3 Exam 300 : Mixed Environments
      • LPIC-3 Exam 303 : Security
      • LPIC-3 Exam 304 : Virtualization and High Availability
    • LPIC-2 Certified Linux Engineer
    • LPIC-1 Linux Administrator
    • LPI Linux Essentials for Raspberry Pi
    • LPI Linux Essentials
  • Operating System Tutorials
    • Linux Foundation Training
    • Solaris 11 OCA 1ZO-821
    • Learning Ubuntu
    • Learning SUSE
    • Red Hat and CentOS Training
      • RHCE – EX294 – Automation With Ansible
      • RHCSA – System Admin 1 – RH124
      • RHCSA – System Admin 2 – RH134
  • Scripting – the power of repetition!
    • Java 7 OCA Exam 1ZO-803
    • General Java Tutorials
    • Learn C Programming using Linux and the Raspberry Pi
    • Ruby Scripting in Linux
    • Scripting with PowerShell
    • PERL Scripting in Linux
    • Learn Shell Scripting with BASH
    • Master Editing Text Files Using VIM
  • Linux Technologies
    • Learning PUPPET
    • openLDAP Directories on Linux
    • Monitoring with Nagios Core
    • Linux File-Systems
    • Learning SAMBA
    • Apache HTTPD Server
    • Learning PHP
    • MYSQL
  • OpenStack
    • Pluralsight
    • Udemy
    • Raspberry Pi Tutorials
    • Citrix Videos
  • Online Instructor-led Courses
    • Red Hat Enterprise Linux System Administration 1 – RH124
    • SELinux Masterclass
    • Bash Scripting Masterclass
    • Nftables Masterclass

© 2021 The Urban Penguin · All Rights Reserved

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok