# systemd & cron — Linux

Source: https://www.geekswithgeeks.com/en/linux/linux-systemd-cron

> Managing services, and scheduling recurring jobs.

## systemctl — manage services

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

```bash
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.

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

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

- [ ] systemctl
- [x] cron
- [ ] scp

*Answer:* cron. cron is Linux's built-in job scheduler for recurring tasks.
