Sep 13, 2016, 12:30

CoreOS and crontab

CoreOS does not have crontab and should not. It uses new concept of Timers for Services.

For instance I have to reindex Sphinx database in container every 15 minutes, how should I do this?

Proper way is to do like this:

  1. create service reindex.service
    sudo vim /etc/systemd/system/reindex.service
[Unit]
Description=Reindexes sphinx container

[Service]
Type=oneshot
ExecStart=/usr/bin/docker exec itservice_search_1 /index.sh
  1. create timer for reindex service:
    sudo vim /etc/systemd/system/reindex.timer
cat		Output the contents of a submitted unit
[Unit]
Description=Run reindex.service every 10 minutes

[Timer]
OnCalendar=*:0/15

Next, we should enable this service and timer like this:

sudo systemctl enable reindex.service
sudo systemctl enable reindex.timer
sudo systemctl start reindex.timer

You can control your timers like:

systemctl list-timers

and watch service logs

journalctl -f -u reindex.service
Share
Pin