Variables in linux Systemd Timer
Budget: $80 – $100 USD
One of my users wants to set up a timer that can take values as variables from a file.
Example.
1. File where variable value 'testvar="22-4-7"' is set - /home/user/timertest.conf
2. in the testing.timer, user wants to load $testvar value.
Location of the file with variable values can be anywhere, ive just given this as an example.
Simple example below.
Thank you
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$ nano /home/user/timertest.conf
~~~~~~~~~~~~~~
# content of /home/user/timertest.conf
testvar="22-4-7"
~~~~~~~~~~~~~
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$ /etc/systemd/system/testing.timer
~~~~~~~~~~~~~~~~~~~~~
# content of /etc/systemd/system/testing.timer
[Unit]
Description=testing
# load the content of /home/user/timertest.conf & use its value in OnCalender=${testvar}
[Timer]
OnCalendar=${testvar}
Unit=testing.service
[Install]
WantedBy=timers.target
~~~~~~~~~~~~~~~~~~~~~
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Example.
1. File where variable value 'testvar="22-4-7"' is set - /home/user/timertest.conf
2. in the testing.timer, user wants to load $testvar value.
Location of the file with variable values can be anywhere, ive just given this as an example.
Simple example below.
Thank you
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$ nano /home/user/timertest.conf
~~~~~~~~~~~~~~
# content of /home/user/timertest.conf
testvar="22-4-7"
~~~~~~~~~~~~~
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
$ /etc/systemd/system/testing.timer
~~~~~~~~~~~~~~~~~~~~~
# content of /etc/systemd/system/testing.timer
[Unit]
Description=testing
# load the content of /home/user/timertest.conf & use its value in OnCalender=${testvar}
[Timer]
OnCalendar=${testvar}
Unit=testing.service
[Install]
WantedBy=timers.target
~~~~~~~~~~~~~~~~~~~~~
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||