When cleanup.timer fires, start archive-cleanup.service with a different basename.
Which [Timer] line is appropriate?
Unit= names the unit started when the timer fires; if omitted, the matching basename service is normally used.
Detailed explanation
Unit=archive-cleanup.serviceCorrect. Unit=archive-cleanup.service selects the service to activate.
Correct. Unit=archive-cleanup.service selects the service to activate.
Service=archive-cleanup.serviceIncorrect. Service= is not the timer target directive.
Incorrect. Service= is not the timer target directive.
Requires=archive-cleanup.serviceIncorrect. Requires= expresses a dependency rather than the timer's activation target.
Incorrect. Requires= expresses a dependency rather than the timer's activation target.
ExecStart=archive-cleanup.serviceIncorrect. ExecStart belongs in a service unit and specifies a command.
Incorrect. ExecStart belongs in a service unit and specifies a command.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s\n' '[Timer]' 'Unit=archive-cleanup.service' | grep '^Unit='Expected result
Unit=archive-cleanup.serviceKey points
- Unit selects target
- Different basename
- ExecStart belongs to service
Notes
- Environment: grep / 合成timer unit
- 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.