Last active
December 20, 2023 17:39
-
-
Save braindevices/c5c0d0664af43164729296ca8e5a7f21 to your computer and use it in GitHub Desktop.
Revisions
-
braindevices revised this gist
Dec 20, 2023 . 1 changed file with 10 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -44,20 +44,26 @@ systemctl status test-timer.timer systemctl status test-timer.service cat ${logfile} # touch /etc/systemd/system/test-timer.service # touch /etc/systemd/system/test-timer.timer sleep 10 echo "now is $(date)" systemctl -T -o verbose daemon-reload systemctl -T -o verbose stop test-timer.timer systemctl -T -o verbose start test-timer.timer sleep 1 systemctl status --no-pager test-timer.timer systemctl status --no-pager test-timer.service cat ${logfile} # touch /etc/systemd/system/test-timer.service # touch /etc/systemd/system/test-timer.timer sleep 10 echo "now is $(date)" systemctl -T -o verbose daemon-reload systemctl -T -o verbose stop test-timer.timer systemctl -T -o verbose start test-timer.timer sleep 1 systemctl status --no-pager test-timer.timer systemctl status --no-pager test-timer.service cat ${logfile} -
braindevices created this gist
Dec 17, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,63 @@ #!/bin/bash set -x systemctl -T -o verbose daemon-reload systemctl -T -o verbose disable --now test-timer.timer set -e wait_secs=20 run_at_time=$(date -d "+${wait_secs}sec" +"%H:%M:%S") logfile=/tmp/test-timer-output if [ -f ${logfile} ] then rm ${logfile} fi cat > /etc/systemd/system/test-timer.service <<EOL [Unit] Description=Run test [Service] ExecStart=/bin/bash -c "date >> ${logfile}" EOL cat > /etc/systemd/system/test-timer.timer <<EOL [Unit] Description=A test timer at ${run_at_time} [Timer] OnCalendar=*-*-* ${run_at_time} Unit=test-timer.service [Install] WantedBy=timers.target EOL systemctl -T -o verbose daemon-reload systemctl -T -o verbose enable --now test-timer.timer set +e echo "expect run at ${run_at_time}" echo "now is $(date), wait ${wait_secs}secs" sleep ${wait_secs} echo "now is $(date)" systemctl status test-timer.timer systemctl status test-timer.service cat ${logfile} touch /etc/systemd/system/test-timer.service touch /etc/systemd/system/test-timer.timer sleep 10 echo "now is $(date)" systemctl -T -o verbose daemon-reload systemctl -T -o verbose stop test-timer.timer systemctl -T -o verbose start test-timer.timer cat ${logfile} touch /etc/systemd/system/test-timer.service touch /etc/systemd/system/test-timer.timer sleep 10 echo "now is $(date)" systemctl -T -o verbose daemon-reload systemctl -T -o verbose stop test-timer.timer systemctl -T -o verbose start test-timer.timer cat ${logfile}