Ramlog
Aller à la navigation
Aller à la recherche
http://habrahabr.ru/post/272279/
/usr/bin/ramlog :
#!/bin/sh . /lib/lsb/init-functions start() { log_begin_msg "RAMLOG: Read files from disk.." tar xfz /var/ram_log.tar.gz -C / log_end_msg 0 } stop() { log_begin_msg "RAMLOG: Write files to disk.." tar cfz /var/ram_log.tar.gz --directory=/ var/log/ log_end_msg 0 } case "$1" in start) start ;; stop) stop ;; flush) stop ;; *) echo "Usage: $0 {start|stop|flush}" exit 1 esac
chmod +x /usr/bin/ramlog
/etc/systemd/system/ramlog.service :
[Unit] Description=Ramlog After=local-fs.target Before=cron.service syslog.service [Service] Type=oneshot RemainAfterExit=yes ExecStart=/usr/bin/ramlog start ExecStop=/usr/bin/ramlog stop [Install] WantedBy=multi-user.target
/etc/crontab:
#flush log to disk every 2h 0 */2 * * * /usr/bin/ramlog flush >/dev/null 2>&1
/etc/fstab :
tmpfs /var/log tmpfs nodev,nosuid 0 0
insserv systemctl enable ramlog.service systemctl start ramlog.service