`at` vs `cron`: when to use which tool for one-time tasks in Linux?

MarGib July 03, 2026
🌐 🇵🇱 Polski · 🇬🇧 EN

Task scheduling in Linux is not just a matter of convenience, but often a necessity. When dealing with one-time actions — such as running a backup at a specific time or sending a notification after a long process finishes — the `at` and `cron` tools seem like the natural choices. But which one works better? Where is the line between simplicity and flexibility, and when does one of them fail?

Terminal Linux prezentujący porównanie komend at i cron — po lewej stronie tabela z zadaniami jednorazowymi, po prawej zadaniami cyklicznymi.
Comparison of Linux terminal task scheduling tools — simplicity of at on the left, complexity of cron on the right.

Basic differences between `at` and `cron` — what to know before choosing

Both at and cron are used for task scheduling, but their approach to this topic differs significantly. at was created with one-time events in mind, which are meant to run at a strictly defined moment in the future. Its syntax is intuitive and clear, making it an ideal tool for quickly scheduling an action that should not repeat. On the other hand, cron is a more powerful tool, optimized for recurring tasks — those that should run every hour, every day, every week, or at any user-defined time interval.

The following table presents the key differences between these tools:

Criterion at cron
Task type One-time (e.g., "run script tomorrow at 15:00") Recurring (e.g., "run script every 2 hours")
Syntax Simple: echo "komenda" | at 14:30 2024-05-20 Complex: requires editing crontab (e.g., 30 14 20 5 * /ścieżka/skrypt)
Date flexibility Very high: supports complex patterns (e.g., "now + 30 minutes", "tomorrow at midnight") Limited: time intervals only (e.g., every minute, every hour)
Priorities No priorities — order depends on addition time Ability to set priorities by user (e.g., using nice)
Logging Standardly saves commands and output to /var/log/atd (depending on distribution) Logs in /var/log/syslog or /var/log/cron (depending on system)

When `at` works better than `cron` — practical examples

The choice between at and cron depends primarily on the nature of the scheduled task. Below you will find specific scenarios where at is not only a convenient but also a safe choice:

  • Executing a one-time action at a specific time — e.g., sending an email in 10 minutes at 15:00:
    echo "echo 'Temat: Raport dzienny' | mail -s 'Raport' admin@example.com" | at 15:00

    In this case, at allows for precise specification of the execution time without the need to create an entry in crontab.

  • Automating tasks dependent on external events — e.g., starting a file conversion after its download finishes:
    wget https://example.com/duzy_plik.iso && echo "/ścieżka/do/konwersji.sh" | at now + 5 minutes

    Thanks to at, you can schedule an action to execute right after the previous process finishes, even if you don't know exactly when that will happen.

  • Prototyping and testing scripts — e.g., quickly checking script behavior at a specific hour:
    echo "ls -la /tmp > /var/log/test.log" | at now + 2 minutes

    This is much faster than editing crontab, especially in development environments.

  • Resource-constrained environments — e.g., Docker containers with a minimal image (e.g., Alpine Linux), where cron is not available or is too resource-intensive:
    echo "backup.sh" | at 02:00 tomorrow

Comparative example:

Suppose you want to schedule a backup for 2:00 AM. Using at, it looks like this:

echo "/ścieżka/do/backup.sh" | at 02:00 2024-05-21

Conversely, with cron, you would have to define an entry in crontab:

0 2 * * * /ścieżka/do/backup.sh

The first solution is clearer and less prone to syntax errors, especially for users who rarely use cron.

Technical limitations of `at` — what can go wrong?

Despite its advantages, at is not a perfect tool. Its main limitations stem from its simplicity and specific purpose. Here are the most common problems users may encounter:

1. Lack of user environment support

at runs tasks in a minimal environment, often ignoring variables defined in .bashrc or .profile. This can lead to errors if the script depends on specific environment variables (e.g., $PATH).

Solution: Define the environment in the script or use full paths for commands:

echo "#!/bin/bash
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
/ścieżka/do/backup.sh" > /tmp/backup_env.sh
echo "/tmp/backup_env.sh" | at 02:00

2. Job queue issues

If the system is overloaded, at tasks may be delayed or skipped. This happens because the atd daemon has no prioritization mechanism — it operates on a FIFO (First-In-First-Out) queue basis.

Solution: Monitor the job queue and remove old or unnecessary entries:

atq  # Lista zadań w kolejce
atrm 123  # Usunięcie zadania o ID 123

3. Permissions — who can use `at`?

By default, access to at is restricted by the /etc/at.allow and /etc/at.deny files. If a user is not listed in either of them, the system will return an error:

You do not have permission to use at.

Solution: Add the user to /etc/at.allow or remove them from /etc/at.deny:

echo "użytkownik" | sudo tee -a /etc/at.allow

4. `atd` daemon errors

Sometimes the atd daemon does not work correctly, resulting in tasks not being executed. The most common causes are:

  • The daemon was not started: sudo systemctl enable --now atd
  • Lock file issue: remove /var/run/atd.pid and restart the daemon
  • Lack of free disk space (tasks are saved in /var/spool/at)

Diagnostics: Check the daemon status:

sudo systemctl status atd
journalctl -u atd --since "1 hour ago"

5. Time zone handling

at does not always account for the user's time zone. This can lead to unexpected results if the user is operating in a different time zone than the system.

Solution: Use the TZ variable in the script or explicitly specify the time in UTC:

echo "TZ=UTC /ścieżka/do/skrypt.sh" | at 02:00

Installing `at` on popular distributions — a step-by-step guide

Although at is widely available, it is not always installed by default. Below you will find instructions for the most popular Linux distributions:

Distribution Installed by default? Package to install Additional steps
Debian / Ubuntu No at Start daemon: sudo systemctl enable --now atd
RHEL / CentOS / Fedora Yes (since RHEL 7+) Check if daemon is running: sudo systemctl status atd
Arch Linux No at
openSUSE No at
Alpine Linux Yes Daemon starts automatically with busybox

Installation on Debian/Ubuntu:

sudo apt update
sudo apt install at
sudo systemctl enable --now atd

Installation on Arch Linux:

sudo pacman -S at

Checking if the daemon is running:

sudo systemctl status atd

Alternatives to `at` — when to consider other tools?

Although at is an excellent solution for one-time tasks, in some cases it is worth considering alternatives. Below we compare the most popular ones:

`systemd timers` — more flexible but more complex

systemd timers is a tool built into the systemd system, which offers greater flexibility than at, but requires knowledge of .timer and .service file syntax. It is ideal for users who already use systemd and want to integrate task scheduling with other system services.

Example: Create a file /etc/systemd/system/backup.timer:

[Unit]
Description=Backup o północy

[Timer]
OnCalendar=*-*-* 02:00:00
Persistent=true

[Install]
WantedBy=timers.target

Then activate the timer:

sudo systemctl enable --now backup.timer

Pros:

  • Precise triggers (e.g., based on system events)
  • Better integration with systemd logs
  • Ability to run tasks in response to system events

Cons:

  • Syntax is more complex than at
  • Requires knowledge of systemd

`fcron` — for recurring tasks with irregular intervals

fcron is an alternative to cron that offers greater flexibility in defining recurring tasks. It is particularly useful in environments where tasks need to run irregularly, e.g., "every 3 days" or "every other Tuesday".

Example: Define a task in /etc/fcrontab:

3 0 * * 1,3,5 /ścieżka/do/skrypt.sh

This means the script will run every Monday, Wednesday, and Friday at 3:00.

Pros:

  • Support for tasks with irregular intervals
  • Better handling of environments with limited computing power

Cons:

  • Less popular than cron
  • Less documentation and community support

`anacron` — for systems with non-continuous operation

anacron is a tool designed for systems that are not running all the time (e.g., laptops). It ensures that scheduled tasks are executed even if the system was powered off at the scheduled time.

Example: Define a task in /etc/anacrontab:

7 10 backup.daily /ścieżka/do/backup.sh

This means the script will run every 7 days; if the system was off, it will run upon the next startup.

Pros:

  • Works even with irregular system operation
  • Simple configuration

Cons:

  • Limited to daily/weekly tasks
  • Not suitable for one-time tasks

Security when using `at` — how to avoid pitfalls?

Although at is a simple tool, its improper use can lead to security issues. Here are best practices that will help you avoid the most common pitfalls:

1. Restrict access to `at`

By default, access to at is controlled by the /etc/at.allow and /etc/at.deny files. The safest approach is to create the /etc/at.allow file and place only authorized users in it.

sudo touch /etc/at.allow
echo "admin" | sudo tee -a /etc/at.allow
echo "developer" | sudo tee -a /etc/at.allow

Users not listed in either file will not be able to use at.

2. Avoid sensitive commands in the `at` queue

at tasks are saved in /var/spool/at in a format readable by administrators. If you plan to execute a command that contains passwords or sensitive data, consider using scripts with restricted permissions or external secret management tools.

3. Log task results

To monitor task execution, redirect the output to a log file:

echo "/ścieżka/do/skrypt.sh > /var/log/at_job.log 2>&1" | at 02:00

This will allow you to easily verify whether the task completed successfully.

4. Remove old tasks

Tasks that should have been completed long ago should be removed from the queue. You can do this manually using atrm or automate this process with a simple script.

# Usuń wszystkie zadania starsze niż 7 dni
atq | awk '$1 < systime() - 604800 {print $1}' | xargs -I {} atrm {}

5. Avoid running `at` tasks as root

If possible, run tasks from a user account with minimal privileges. Using root should be limited to tasks that require administrator privileges.

Summary — when to choose `at` and when `cron`?

The choice between at and cron depends primarily on the nature of your task:

  • Use at when:
    • You are dealing with a one-time task at a strictly defined time.
    • You need a simple and fast scheduling method.
    • You are working in an environment where cron is not available (e.g., minimal containers).
    • You want to quickly test script behavior.
  • Use cron when:
    • You are dealing with a recurring task (e.g., every hour, every week).
    • You need greater flexibility in defining intervals.
    • You want to prioritize tasks or set time limits.

If you are still in doubt, start with at. Its simplicity and readability make it an excellent starting point for task automation in Linux. When your needs go beyond one-time actions, you can easily switch to cron or its alternatives.

Sources

Facebook X E-mail

Comments

Dodaj komentarz

Explore

Labels

news 11 Windows 10 browsers 10 Automation 9 Opera 9 Security 9 Technology 8 facebook 8 web applications 8 Software 7 automation 7 chrome 7 coaching 7 curiosities 7 technology 7 www 7 Docker 6 LLM 6 Microsoft 6 Mind 6 Programming 6 Web browser 6 entertainment 6 new technologies 6 Anthropic 5 Cybersecurity 5 God 5 Productivity 5 Red Hat 5 books 5 education 5 CentOS 4 Claude AI 4 Open Source 4 OpenAI 4 RedHat 4 Ubuntu 4 Vivaldi 4 Windows 10 4 Windows system administration 4 algorithms 4 applications 4 containers 4 health 4 machine learning 4 people 4 photography 4 trivia 4 Administration 3 Android 3 BIG DATA 3 Business 3 ChatGPT 3 Claude 3 FAQ 3 FIFA 3 Firefox 3 Google projects 3 Homelab 3 Local AI 3 Personal Development 3 Personal Finance 3 Privacy 3 Programs 3 bash 3 communication 3 computer science 3 cybersecurity 3 extensions 3 faith 3 future of work 3 games 3 good movie 3 help 3 human 3 interesting websites 3 interface 3 media 3 money 3 n8n 3 network 3 opensource 3 personal competencies 3 personal development 3 programming 3 psychology 3 reading 3 religion 3 security 3 system administration 3 tools 3 virtualization 3 web browser 3 websites 3 AI agents 2 AI assistant 2 Asus 2 Career 2 Centos 2 Cloud 2 Codex 2 Configuration 2 Debian 2 Debugging 2 DevOps 2 Docker Machine 2 Drones 2 Education 2 Free Red Hat 2 Guide 2 Hardware 2 Intel 2 Intelligence 2 Japan 2 Job Market 2 Kernel 2 Machine Learning 2 Medicine 2 Mythos 2 Netflix 2 Performance 2 Poland 2 Psychology 2 Puppeteer 2 RHEL7 2 RSS 2 Rocky Linux 2 Sakana AI 2 Self-hosting 2 Servers 2 Software Engineering 2 Windows administration 2 Windows errors 2 ansible 2 better life 2 brain 2 chat 2 children 2 cloud storage 2 communicator 2 communities 2 computer intelligence 2 computers 2 conferences 2 creativity 2 curl 2 cyberattacks 2 data 2 death 2 documentary 2 earning 2 emotions 2 file storage 2 fix 2 free application 2 free courses 2 free knowledge from the internet 2 free training 2 genius 2 hacker 2 investments 2 knowledge 2 learning 2 local AI 2 mind manipulation 2 mind programming 2 mindfulness 2 mobile 2 mobile apps 2 mobile phones 2 motivation 2 movie 2 multimedia 2 open-source 2 personal thoughts 2 photos 2 plugin 2 podcast 2 privacy 2 prompt 2 shell 2 software 2 technological innovations 2 terminal 2 torrent 2 trick 2 wealth 2 weather 2 web 2 wisdom 2 youtube 2 (Treści etykiet nie zostały podane w treści wejściowej) 1 120B models 1 21st Century Skills 1 2FA 1 2nm processors 1 64 bit 1 7 1 ACT therapy 1 AGI 1 AI Agents 1 AI Frameworks 1 AI History 1 AI Safety 1 AI benchmarks 1 AI censorship 1 AI ethics 1 AI future 1 AI governance 1 AI in healthcare 1 AI in school 1 AI in sports 1 AI optimization 1 AI safety 1 AI superchips 1 AIMP 1 AMD ROCm 1 Acquisition 1 Alan Watts 1 Alexander Gerst 1 AlmaLinux 1 Alpine Linux 1 Andrej Karpathy 1 Anonymous 1 Apache 1 Apple 1 Apple 2025 1 Apple Silicon 1 Aria AI 1 Audacity 4 1 AutoGen 1 Banking 1 Bash 1 Big Data 1 Bill Warner 1 Biotechnology 1 Black Mirror 1 Blackwell B100 1 Blockchain 1 Bonding 1 Bono 1 Business and Finance 1 C++ 1 CPU 1 CUA 1 CUDA 1 Career Development 1 Chat GPT 1 Chemtrails 1 ChildOnlineSafety 1 Claude Fable 1 Coaching 1 Computer-Using Agent 1 Constitutional AI 1 Copilot 1 Copilot for Finance 1 Couching 1 CrewAI 1 Cryptocurrencies 1 Cyberbullying 1 Dario Amodei 1 Darwin 1 Data Science 1 Deep Learning 1 DeepSeek 1 Deepseek 1 Deluge 1 Devin AI 1 Diagnostics 1 Digitalization 1 Docker containers 1 Drivers 1 Dystrybucje 1 EA GAMES 1 EA SPORTS 1 Earth AI 1 Economics 1 Email 1 Emigration 1 Enterprise Linux 1 Entrepreneurship 1 Error 1 European Funds 1 Excel 1 FIFA 16 1 Fable 1 Facebook 1 Fact-checking 1 Fake News 1 Flannel 1 Flynn Effect 1 Football 1 Foundation 1 Free 1 Free Software 1 Free software 1 Fugu Ultra 1 Future 1 Future of Finance 1 Future of Work 1 GDPR 1 GLM-5.2 1 GPT 1 GPT-4 1 GPT-4.5 1 GPU Cloud 1 GUI 1 Gemini 1 Generation Z 1 GitHub 1 Golden Gate 1 Google Assistant 1 Google Gemma 4 12B 1 Google Research 1 Google activity 1 GoogleFamilyLink 1 Got Talent 1 Gregory Kurtzer 1 Guides 1 HTML 1 Hardware Requirements 1 Health Intelligence 1 Hygge 1 IAM 1 IBM 1 IDE 1 IQ 1 ISIS 1 ISS 1 IT 1 IT history 1 Intelligent email 1 Internet Browser 1 Internet browser 1 InternetEducation 1 Interview 1 Islam 1 Islamic State 1 Jacquard 1 JavaScript 1 Jboss 1 Jetson Thor price 1 Joel Pearson 1 Kali Linux 1 Khan Academy 1 Kylian Mbappé 1 LLM Deployment 1 Labor Market 1 Legal regulations 1 LibreOffice 1 Linux automation 1 Linux diagnostics 1 Linux system tools 1 Linux task management 1 Linux task scheduling 1 Logs 1 Londoners 1 MFA 1 MLX 1 Maps 1 MarGib_Film 1 Marek Jankowski 1 Mars helicopter 1 Material Design 1 Matt Pocock 1 Microsoft 365 1 Military 1 Mindfulness 1 Miłosz Brzeziński 1 Monitoring 1 MrBallen 1 My take 1 NATO 1 NTFS 1 NVIDIA 1 NVIDIA Blackwell 1 NVIDIA Jetson Thor 1 National security 1 Navy SEALs 1 Neural Networks 1 New 1 Nginx 1 No comment 1 Node.js 1 Non-profit 1 Notion 1 Nvidia 1 Odysseus 1 Opera Air 1 Opera Neon 1 Opera Touch 1 Operating Systems 1 P2P 1 PARP 1 Pac-Man 1 Pekao S.A 1 Peperclips 1 Perceptron 1 Personal development 1 Philosophy 1 Photoshop 1 Playwright 1 Poles 1 PostgreSQL 1 PowerShell 1 Project Maven 1 Project TANGO 1 Proton Drive 1 PyTorch 1 Python 1 Qt Creator 1 Quotes 1 RHEL8 1 Raspberry PI 1 Raspberry Pi 1 Raspbian 1 Red Hat 8 1 Red Hat Enterprise Linux Developer Suite 1 RedHat 8 1 Regex 1 Robo-advisors 1 Rust 1 SMEs 1 SUSE 1 SafeInternet 1 SaferInternetDay 1 Safety 1 Sakana Fugu 1 Search 1 Sector 3.0 Festival 1 Security Auditing 1 September 23 2017 1 Server Administration 1 Smart City 1 Snip. 1 Social Media 1 Soli 1 Solo Projects 1 Solopreneurship 1 Something from myself 1 Sound 1 Sovereign AI 1 Sport 1 Steam Deck 1 SysAdmin 1 System Administration 1 Tech 1 TensorFlow 1 The Shack 1 Time Management 1 Tips 1 Tokenomics 1 Tools 1 Tribler 1 Tutorial 1 U.S. 1 U.S. government 1 U2 1 UI testing 1 USB 1 Ubuntu 26.04 1 Ubuntu Server 1 VentuSky 1 VirtualBox 1 Virtualization 1 WBC 1 WSL 3 1 WWDC 2026 1 WWDC26 1 Warsaw 1 Weave 1 Web Scraping 1 Websites 1 Windows update 1 Work 1 Workflow 1 World Cup 1 World Cup 2026 1 World Wide Web 1 X-Files 1 X-files 1 YouTube 1 ZUS 1 ZenFone 1 a drop of motivation 1 about this blog 1 account security 1 achieving goals 1 ad blocking 1 addiction 1 administrator 1 aids 1 animations 1 assertiveness 1 at one-time tasks 1 at vs cron 1 atd daemon 1 audio 1 audio editing 1 automateit 1 autonomous cars 1 awareness 1 bank 1 bash on windows 1 bat files 1 batch 1 battery 1 beliefs 1 beta 1 better living 1 better quality 1 big data 1 bin/bash 1 biodiversity 1 blocking 1 blogger 1 body language 1 bookmarks 1 boot 1 bootable usb 1 boxing 1 brain-computer interfaces 1 browser automation 1 business intelligence 1 c# 1 calc 1 campaign 1 cards 1 centralized platforms 1 chemistry 1 clearance 1 cli tools 1 clothing industry 1 cmd 1 code editor 1 cognitive psychology 1 coldplay 1 command history 1 command line 1 command prompt 1 comments 1 computer interaction 1 concentration 1 configuration management 1 conntrack 1 console 1 conspiracy 1 conspiracy theories 1 controversial 1 converter 1 corporate world 1 cost optimization 1 courage 1 courses 1 courses for free 1 critical thinking 1 dark mode 1 data security 1 date and time 1 deep learning 1 democracy 1 design systems 1 developer tools 1 digital clothing 1 digitalization 1 disqus 1 document 1 document conversion 1 dreams 1 drop of motivation 1 dubai 1 dying 1 e-book 1 eBPF 1 economy 1 ecosystem restoration 1 elections 1 end of the world 1 end of world 1 energy 1 energy efficiency 1 environment and health 1 ethical AI 1 evolution 1 excel 1 exploitation 1 extreme 1 file sharing 1 file size 1 film zone 1 flash drive 1 flat earth 1 flying 1 food 1 football 1 for sale 1 format change 1 free 1 free software 1 friend location 1 future of education 1 future of humanity 1 future of transport 1 future skills 1 game 1 geoengineering 1 google chat 1 graphics 1 graphics editors 1 growing up 1 hacking 1 happiness 1 hard-link 1 hashing 1 hedonic adaptation 1 helion 1 history 1 hobby 1 home hosting 1 hostname 1 hostnamectl 1 how many people live on earth 1 humanity 1 humor 1 iOS 1 iPhone 18 Pro 1 iPhone launch 1 iftop 1 immortality 1 influencer criticism 1 infrastructure 1 innovation 1 installation 1 intelligence 1 internet applications 1 investing 1 javascript 1 job market 1 kuba wojewódzki 1 labor market 1 language models 1 light 1 login 1 loop-audit 1 loop-cost 1 loop-init 1 macOS 1 magic 1 make life harder 1 making money 1 markdown 1 markitdown 1 material design 1 meditation 1 memory 1 messenger 1 meteorology 1 microsoft 1 microtargeting 1 mobile applications 1 mobile photography 1 mounting 1 mp3 player 1 music 1 music player 1 mysteries 1 national defense 1 nature conservation 1 net use 1 nethogs 1 network monitoring 1 network resources 1 network security 1 networking 1 neurobiology 1 neuropsychology 1 neurotechnology 1 new life 1 new player 1 new things 1 nftables 1 office 1 onboarding 1 one-time cron 1 onestep4red 1 online 1 online courses 1 open source 1 operating systems 1 outage 1 paper clips 1 paradox of the fulfilled dream 1 parenting 1 parents 1 password 1 password change 1 password policy 1 password recovery 1 password security 1 pdf 1 penetration testing 1 performance 1 perseverance 1 personal data 1 philosophy 1 phishing 1 php 1 plague 1 player 1 poison 1 police 1 predictions 1 promissory notes 1 protection 1 questions 1 radar 1 red 1 regulations 1 relax 1 relaxation 1 remote work 1 reportage 1 rest 1 risk 1 robotaxi 1 root 1 routing 1 satellite data 1 science 1 scientific facts 1 scraping 1 screen 1 screenshot 1 self-development 1 series 1 show 1 skydive 1 sleep 1 small big company 1 smart clothing 1 smartphone 1 smartphones 1 social engineering 1 social media 1 society 1 space 1 sport 1 sports 1 spreadsheet 1 stalking 1 statistics 1 streaming 1 sub-millimeter sensor 1 success 1 symbolic link 1 syngrapha 1 system acceleration 1 tablet 1 talk show 1 technical documentation 1 technology regulations 1 television 1 terrorism 1 testing 1 the world in numbers 1 threats 1 time management 1 time travel 1 timelapse 1 tips 1 two-factor authentication 1 ubuntu 1 upbringing 1 users 1 viral 1 virtualbox 1 walking 1 walking meetings 1 weather forecasting 1 webmaster 1 windows automation 1 word processing 1 work 1 work automation 1 world 1 world cup 2026 1 world wide web 1 you are a miracle 1 zeitgeist 1

Blog archive

Table of contents