command line - How to execute a script periodically without using crontab? - Ask Ubuntu


how execute script periodically crontab without using crontab?

please note executed script should not fire script , schedule 'sleep' command, expect have same functionality crontab should not present in crontab list , should not stop when terminal or session ended,

crontab without croning it.

the modern option use systemd timer unit. requires creating systemd unit defines job want periodically run, , systemd.timer unit defining schedule job.

assuming want run job regular user, put these files in $home/.config/systemd/user:

my-job.service

[unit] description=job needs periodic execution  [service] execstart=/path/to/your/script 

my-job.timer

[unit] description=timer periodically triggers my-job.service  [timer] oncalendar=minutely 

then enable newly created units, , start timer:

$ systemctl --user enable my-job.service my-job.timer $ systemctl --user start my-job.timer 

to verify timer set:

$ systemctl --user list-timers next                         left     last                         passed unit         activates wed 2016-11-02 14:07:00 eat  19s left wed 2016-11-02 14:06:37 eat  3s ago my-job.timer my-job.service 

journalctl -xe should show log entries of job being run.

refer man systemd.timer many options configuring timer behaviour (including randomised starting, waking computer, persistence across downtime, timer accuracy, etc.), , man systemd.unit excellent documentation on systemd , systemd units in general.


Comments

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User