cronie-crond / cronie

Cronie cron daemon project
Other
481 stars 81 forks source link

HOW TO: install in Ubuntu #168

Open asterissco opened 10 months ago

asterissco commented 10 months ago

Cronie is a cron implementation used in red-hat that supports the CRON_TZ prefix with which you can set a time zone of a cron statement

The service works well, but the crontab editor that comes with it gives a lot of permission problems, so we are going to install cronie by hand, leaving everything else the same

Compilation

qrms@pruebas-cron:~$ sudo su -
[sudo] password for qrms: 
root@pruebas-cron:~# apt-get install -y build-essential
root@pruebas-cron:~# wget https://github.com/cronie-crond/cronie/releases/download/cronie-1.7.0/cronie-1.7.0.tar.gz
root@pruebas-cron:~# tar xzf cronie-1.7.0.tar.gz 
root@pruebas-cron:~# cd cronie-1.7.0/
root@pruebas-cron:~/cronie-1.7.0# ./configure 
root@pruebas-cron:~/cronie-1.7.0# make

Creating and mapping folders with links

root@pruebas-cron:~/cronie-1.7.0# mkdir -p /usr/local/var/spool/
root@pruebas-cron:~/cronie-1.7.0# ln -s /var/run/ /usr/local/var/run
root@pruebas-cron:~/cronie-1.7.0# ln -s /var/spool/cron/crontabs/ /usr/local/var/spool/cron
root@pruebas-cron:~/cronie-1.7.0# ln -s /etc/cron.d/ /usr/local/etc/cron.d

We copy the binary to /usr/local/bin and modify the cron service in systemd so that it loads cronie

root@pruebas-cron:~/cronie-1.7.0# cp src/crond /usr/local/bin/
root@pruebas-cron:~/cronie-1.7.0# vim /lib/systemd/system/cron.service

[Unit]
Description=Regular background program processing daemon
Documentation=man:cron(8)
After=remote-fs.target nss-user-lookup.target

[Service]
EnvironmentFile=-/etc/default/cron
# ExecStart=/usr/sbin/cron -f $EXTRA_OPTS
ExecStart=/usr/local/bin/crond -f $EXTRA_OPTS
IgnoreSIGPIPE=false
KillMode=process
Restart=on-failure

[Install]
WantedBy=multi-user.target

Reload

root@pruebas-cron:~/cronie-1.7.0# systemctl daemon-reload 
root@pruebas-cron:~/cronie-1.7.0# systemctl restart cron.service 
root@pruebas-cron:~/cronie-1.7.0# systemctl status cron.service 
● cron.service - Regular background program processing daemon
     Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2023-12-26 16:17:17 UTC; 4s ago
       Docs: man:cron(8)
   Main PID: 9520 (crond)
      Tasks: 1 (limit: 2256)
     Memory: 828.0K
     CGroup: /system.slice/cron.service
             └─9520 /usr/local/bin/crond -f

dic 26 16:17:17 pruebas-cron systemd[1]: Started Regular background program processing daemon.
dic 26 16:17:17 pruebas-cron crond[9520]: (CRON) STARTUP (1.7.0)
dic 26 16:17:17 pruebas-cron crond[9520]: (CRON) INFO (Syslog will be used instead of sendmail.)
dic 26 16:17:17 pruebas-cron crond[9520]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 67% if used.)

And it should be working now

t8m commented 10 months ago

It would make sense to have a proper HOWTO document created from this but it would need some cleanup.

asterissco commented 10 months ago

Oks, i do it and send on comment! thank for cronie!

hartwork commented 10 months ago

Ubuntu has a package for cronie by now: Ubuntu mantic (23.10) has cronie 1.6.1, Ubuntu noble (24.04) has cronie 1.7.1. Here's a simplified version of what Ubuntu's 1.7.1 noble package is doing in its debian/rules Makefile:

CONFIG_OPTIONS =
CONFIG_OPTIONS += --disable-anacron
CONFIG_OPTIONS += --with-editor=/usr/bin/sensible-editor
CONFIG_OPTIONS += --with-pam
CONFIG_OPTIONS += --with-selinux
CONFIG_OPTIONS += --with-inotify
CONFIG_OPTIONS += --with-audit

override_dh_auto_configure:
    SPOOL_DIR=/var/spool/cron/crontabs \
          dh_auto_configure CRON_GROUP=crontab -- $(CONFIG_OPTIONS)

override_dh_install:
    dh_install
    install -m 644 debian/etc/cronie.deny       debian/cronie/etc/cron.deny
    install -d -m 755 debian/cronie/lib/systemd/system/
    install -m 644 contrib/cronie.systemd       debian/cronie/lib/systemd/system/cronie.service

If it still needs documentation for older versions of Ubuntu, matching recent packaging closely may be a good idea to minimize future need for migration during update. Just an idea.