The timer unit just defines when something happens to the service unit, and the service unit defines the actual action (in your case: start the script /home/me/skript.sh). foo.timer would control foo.service (you can override that, though). By default, a timer unit starts a service unit with the same name (except for the extension. Note that the timer and the service are two different things, and you need to define both. This means: The timer was triggered 1s ago and will be triggered again in ~14 minutes (at "Sun 14:57:05 CEST"). Jul 01 14:42:05 stratum9 systemd: Started 15 minute timer. brew install flock Run cron job every minute The syntax is: /path/to/your/script To run a script called /home/vivek/bin/foo, type the crontab command: crontab -e Append the following job: /home/vivek/bin/foo Save and close the file. Loaded: loaded (/etc/systemd/system/my-fifteen-minutes.timer enabled vendor preset: enabled)Īctive: active (waiting) since Sun 14:42:05 CEST 1s ago my-fifteen-minutes.timer - 15 minute timer.The command systemctl status my-fifteen-minutes.timer will show something like Systemctl status my-fifteen-minutes.timer rvice Sudo systemctl start my-fifteen-minutes.timer # start the timer "now" (without rebooting): Sudo systemctl enable my-fifteen-minutes.timer # make sure the timer is engaged at startup Put these files in the directory /etc/systemd/system and enable the timer with # make systemd aware of them You need to create two systemd units, one that starts your script, and one for the timer.įile /etc/systemd/system/my-fifteen-minutes.timer: įile /etc/systemd/system/rvice (note the different extension): ĮxecStart=/bin/sh -c "/home/me/skript.sh > /home/me/out.log 2>&1" This is not possible with cron but systemd can do that.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |