Write /etc/cron.d/cleanup to run /usr/local/bin/cleanup as app every day at 04:00.
Which entry is appropriate?
Files in /etc/cron.d use system-crontab format: five time fields, execution user, then command.
Detailed explanation
0 4 * * * /usr/local/bin/cleanupIncorrect. It omits the required execution user.
Incorrect. It omits the required execution user.
app 0 4 * * * /usr/local/bin/cleanupIncorrect. The user must follow the time fields.
Incorrect. The user must follow the time fields.
0 4 * * * app /usr/local/bin/cleanupCorrect. It includes five schedule fields, app, and the command.
Correct. It includes five schedule fields, app, and the command.
0 4 * * app /usr/local/bin/cleanupIncorrect. The weekday field is missing.
Incorrect. The weekday field is missing.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' '0 4 * * * app /usr/local/bin/cleanup' | awk '{print NF, $6}'Expected result
7 appKey points
- cron.d uses system format
- Include a user field
- Command comes last
Notes
- Environment: POSIX awk / 模擬エントリのみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.