but here is a simple way to pass argument from your timer to your unit, and that is use templates
example
create a service with @ i the name
[Unit] Description=test [Service] ExecStart=/bin/echo 'hello from %i'
then your timer can be something like
/etc/systemd/system/me.timer
[Unit] Description=timer for me [Timer] OnUnitActiveSec=10s OnBootSec=10s [email protected] [Install] WantedBy=multi-user.target
you see that now whatever you pass after the @ will become %i in your service file. so now you just
[~] sudo systemctl daemon-reload [~] sudo systemctl start me.timer [~] sudo systemctl status [email protected] ● [email protected] - test Loaded: loaded (/etc/systemd/system/[email protected]; static; vendor preset: enabled) Active: active (running) since Thu 2018-02-08 19:35:38 PST; 7ms ago Main PID: 8899 (echo) Tasks: 1 (limit: 4915) CGroup: /system.slice/system-me.slice/[email protected] Feb 08 19:35:38 algx systemd[1]: Started test. Feb 08 19:35:38 algx echo[8899]: hello from timer
if you want to start the unit from the cli, just give it another param after the @
[~] sudo systemctl start me@cli [~] sudo systemctl status [email protected] ✘ ~ sudo systemctl status [email protected] ● [email protected] - test Loaded: loaded (/etc/systemd/system/[email protected]; static; vendor preset: enabled) Active: inactive (dead) Feb 08 19:32:48 algx systemd[1]: Started test. Feb 08 19:32:48 algx echo[8490]: hello from cli
this way you have a clear distinction on what is timer and what is cli, but you can expand this to any type of trigger... you dont maintain 2 units files, but you have a clear separation because from the point of view of systemd this are 2 different services.
systemd.timertriggers asystemd.serviceunit, so you can use theEnvironmentdirective in the service file. Or install thesystemd-cronpackage, to emulate the good old crontab.