Lesson 31 / 31

systemd & cron

Control services with systemctl and schedule recurring jobs with cron and crontab.

systemctl — manage services

systemd runs background services on most modern distros; systemctl is how you control them.

sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl status nginx

Output:

● nginx.service - A high performance web server
   Active: active (running) since Thu 2026-09-04 09:00:00 IST

cron — schedule recurring jobs

cron runs commands on a schedule you define, using five time fields: minute, hour, day-of-month, month, day-of-week.

crontab -e

crontab -e opens your personal crontab for editing.

# run backup.sh every day at 2:30 AM
30 2 * * * /home/alice/backup.sh

Quick check: Which tool is used to run a script automatically every night at a fixed time?

  • systemctl
  • cron
  • scp
  • grep
Answer

cron — cron is Linux's built-in job scheduler for recurring tasks.

Final quiz 1 of 8

Final quiz

Quick check: Which command shows your current directory?

  • ls
  • cd
  • pwd
  • whoami
Answer

pwd — pwd prints the working directory.

Final quiz 2 of 8

Final quiz

Quick check: What does chmod 755 file set?

  • rw-r--r--
  • rwxrwxrwx
  • r--r--r--
  • rwxr-xr-x
Answer

rwxr-xr-x — 7 = rwx, 5 = r-x.

Final quiz 3 of 8

Final quiz

Quick check: Which command follows a log file live?

  • tail -f
  • cat
  • head
  • wc
Answer

tail -f — tail -f streams new lines as they are written.

Final quiz 4 of 8

Final quiz

Quick check: What does `command > /dev/null 2>&1` do?

  • Appends output to a file
  • Discards stdout and stderr
  • Runs in background
  • Shows only errors
Answer

Discards stdout and stderr — /dev/null swallows everything redirected to it.

Final quiz 5 of 8

Final quiz

Quick check: Which signal cannot be caught or ignored?

  • SIGTERM
  • SIGINT
  • SIGKILL
  • SIGHUP
Answer

SIGKILL — SIGKILL always terminates the process.

Final quiz 6 of 8

Final quiz

Quick check: How do you install a package on Ubuntu?

  • dnf get name
  • pacman -Q name
  • brew add name
  • sudo apt install name
Answer

sudo apt install name — apt is the Debian and Ubuntu package manager.

Final quiz 7 of 8

Final quiz

Quick check: What does PATH do?

  • Lists directories searched for commands
  • Stores your home directory
  • Lists open files
  • Sets the prompt
Answer

Lists directories searched for commands — The shell searches PATH entries in order.

Final quiz 8 of 8

Final quiz

Quick check: Which tool schedules a recurring job?

  • scp
  • cron
  • grep
  • tar
Answer

cron — crontab entries define time fields and commands.