[sisyphus]

.. gbimobou gmail.com
24 13:23:44 MSK 2017


  .


1.    -      "", 
 doit@ - , "  ..."

minutely ...,

hourly  ...,

daily   ...,

weekly  ...,

monhly  ...,

yearly  ....

 , doit   ,      
     do, cron, timers   .

.

# cat /lib/systemd/system/doit  .target
[Unit]
Description=%i timer target
StopWhenUnneeded=yes

# cat /lib/systemd/system/doit  .timer
[Unit]
Description=%i timer

[Timer]
OnCalendar=%i
Persistent=true

#    -  ,     
 :

#RandomizedDelaySec=10min
Unit=doit@%i.target

[Install]
WantedBy=timers.target


2.     :

for time in minute hour dai week month year; do

 for act in enable start; do

  systemctl $act doit@${time}ly.timer

 done

done


3.  ,   , 
    [Install].  :

# cat /lib/systemd/system/logrotate.service
[Unit]
Description=Rotate system logs

[Service]
Nice=19
Type=simple
IOSchedulingClass=2
IOSchedulingPriority=7
ExecStart=/usr/sbin/logrotate /etc/logrotate.conf

[Install]
WantedBy=doit  daily.target


4. , ,  :

systemctl enable <  >


,  - . :

# systemctl list-timers
NEXT LEFT
LAST PASSED UNIT
ACTIVATES
Tue 2017-10-24 18:18:00 IRKT 32s left Tue 2017-10-24
18:17:02 IRKT 25s ago doit  minutely.timer
doit  minutely.target
Tue 2017-10-24 19:00:00 IRKT 42min left Tue 2017-10-24
18:00:12 IRKT 17min ago doit  hourly.timer doit  hourly.target
Wed 2017-10-25 00:00:00 IRKT 5h 42min left
n/a n/a doit  daily.timer
doit  daily.target
Wed 2017-10-25 15:46:49 IRKT 21h left Tue 2017-10-24
15:46:49 IRKT 2h 30min ago systemd-tmpfiles-clean.timer
systemd-tmpfiles-clean.service
Mon 2017-10-30 00:00:00 IRKT 5 days left
n/a n/a doit  weekly.timer
doit  weekly.target
Wed 2017-11-01 00:00:00 IRKT 1 weeks 0 days left
n/a n/a doit  monthly.timer
doit  monthly.target
Mon 2018-01-01 00:00:00 IRKT 2 months 7 days left
n/a n/a doit  yearly.timer
doit  yearly.target

7 timers listed.
Pass --all to see loaded but inactive timers, too.


# ls /etc/systemd/system/doit  daily.target.wants
/etc/systemd/system/doit  minutely.target.wants
/etc/systemd/system/doit  monthly.target.wants
/etc/systemd/system/doit  daily.target.wants:
logrotate.service

/etc/systemd/system/doit  minutely.target.wants:
unbound-stats.service

/etc/systemd/system/doit  monthly.target.wants:
unbound-anchor.service


--
 .
WBR, rednex CIO.
Viber = +7(964)103-65-67
JID = <mailto:>
Skype = $local_part@<mailto:>



Sisyphus