Scheduling work with cron

Cron runs a command for you at the times you choose, so you stop having to remember. These questions cover the five fields of a cron line, the small environment a job runs in, and sending its output somewhere you can read it later.

4 questions 1 task Read the lesson

Questions

Each one is marked as you go, and the explanation arrives straight after, which is the part worth reading.

4 questions, marked as you go.

1 What does the cron line 30 7 * * * /home/bin/backup.sh mean?
2 Why does a cron job need the full path to a script, such as /data/data/com.termux/files/home/bin/backup.sh?
3 In the line 30 7 * * * /home/bin/backup.sh >> /home/backup.log 2>&1, what do the two redirections do?
4 You have installed cron in Termux and written a correct crontab line. Why might the job still never fire?

Tasks

These need your own device. Run the command in Termux, then paste what it printed. The marking looks at what the output means, so spacing, version numbers and ordering do not matter. If you have not installed anything yet, the lesson covers the setup.

Log a job the way cron would

This appends a timestamped line and a result line to a log, the way a scheduled job writes its output, then reads the log back with tail.

Run this in Termux On your own device. Nothing on this page executes it. The command runs in your terminal, and this box only reads what you paste back.

echo "run at $(date +%H:%M)" >> ~/cron-test.log 2>&1; echo "finished ok" >> ~/cron-test.log 2>&1; tail -n 5 ~/cron-test.log
Marking your own work Both halves of this are checked in your browser, with no server involved, so nothing stops you from pasting output you did not run. The tasks are written so that the easiest way to pass one is to actually do it and read the result, which is the whole intention.

All sets Read the lesson