Exercises

Exercises

Create a cronjob that removes all .txt files from your Desktop directory every 3 minutes.

  • Add a file to your Desktop directory for testing purposes:
touch /home/student/Desktop/example-file.txt
Click Here for Answer
*/3 * * * * rm /home/student/Desktop/*.txt

Create a cronjob that would append the current date the first minute of every month to a file called new-month on your Desktop.

Click Here for Answer
1 0 1 * * echo "$(date)" >> /home/student/Desktop/new-month

Questions and Answers

What is a Crontab?

Click Here for Answer

File that holds instructions for the cron daemon.

How do you list the current user’s Crontab?

Click Here for Answer
crontab -l

How do you edit the current user’s Crontab?

Click Here for Answer
crontab -e

How many time parameters are required for a Cronjob?

Click Here for Answer

Five

What would the syntax be to run a cronjob at 5:30 PM every Monday, Wednesday, and Friday?

Click Here for Answer

30 17 * * 1,3,5

What is the syntax to run a cronjob at 5:00 AM the first day of every quarter of the year?

Click Here for Answer

0 5 1 3,6,9,12 *