How to Automate tasks in Linux

Image for post
Image for post

Introduction

export PATH=$PATH:/snap/bin

Prerequisites

$ sudo apt update
$ sudo systemctl enable cronOutput Synchronizing state of cron.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable cron

Scheduling tasks using Crontabs

$ crontab -e
Image for post
Image for post
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
m h dom mon dow command
@hourly  -> 0 * * * *@daily  ->    0 0 * * *@weekly  ->    0 0 * * 0@monthly  ->    0 0 1 * *@yearly  ->    0 0 1 1 *
@reboot  /home/nextwebb/Desktop/filename.script
$ crontab -l
Image for post
Image for post

I’m a Software Engineer 👩‍💻, an avid learner 👨‍🎓 and a community leader 🥑.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store