702-100 practice question 2 of 15

Which line in a cron job runs myscript once per hour?

Full set: 60 questions
Answer options
A: ***** /pathto/myscript
B: 0 * * * * /pathto/myscript Correct answer
C: * 0 * * * /pathto/myscript
D: * * o * * /pathto/myscript
E: * * * o * /pathto/myscript
Correct Answer:
B. 0 * * * * /pathto/myscript
Explanation

A crontab entry has five time-and-date fields, followed by the command to be run. The fields are, in order: minute (0-59), hour (0-23), day of month (1-31), month (1-12), and day of week (0-7). An asterisk () in a field means "every". The entry 0 specifies the command to run at minute 0 of every () hour, on every day of the month, every month, and every day of the week. This schedule precisely executes the script once per hour, at the beginning of each hour.

Why Incorrect

A. runs the script every minute of every hour, resulting in 60 executions per hour.
C. 0 runs the script every minute, but only during the single hour of midnight (00:00).
D. o is syntactically invalid. The character 'o' is not a valid value for the day-of-month field.
E. o is syntactically invalid. The character 'o' is not a valid value for the month field.

References

1. Linux man-pages project. crontab(5) manual page. Section: "DESCRIPTION". This section details the five time fields and the use of the asterisk () wildcard, confirming that 0 executes a command at the top of every hour. Available at: https://man7.org/linux/man-pages/man5/crontab.5.html

2. University of Washington, Paul G. Allen School of Computer Science & Engineering. "CSE 391: System and Software Tools, Lecture 03: Shell Scripting; Cron". Slide 25 provides the example 0 /usr/bin/updatedb and explains it as "run updatedb at the beginning of every hour". Available at: https://courses.cs.washington.edu/courses/cse391/18wi/lectures/03-scripting-cron.pdf

3. The Open Group Base Specifications Issue 7, 2018 edition. IEEE Std 1003.1-2017. crontab utility, Section: "Standard Input". This POSIX standard defines the format of a crontab entry, specifying the five initial fields for time and date. Available at: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/crontab.html

Scroll to Top