Configuring crontab and logs.

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
koyut
Posts: 4
Joined: Mon Feb 13, 2017 3:41 am

Configuring crontab and logs.

Post by koyut »

0 12 * * * /DietPi/dietpi/dietpi-services restart
0 */8 * * * /DietPi/dietpi/dietpi-services restart qbittorent

configured using crontab -e

should I edit the /etc/crontab directly?

I have these in my crontab but does not seem to be running the commands. Where can I find the logs. I tried /var/log/cron /var/log/messages and /var/log/syslog but it does not seem to be there.
User avatar
MichaIng
Site Admin
Posts: 2295
Joined: Sat Nov 18, 2017 6:21 pm

Re: Configuring crontab and logs.

Post by MichaIng »

You can check journalctl for the times where the commands should run. Does nothing appear there?

With which user did you start crontab -e, since it needs to be root user. (sudo) crontab -u root -e would be it then and crontab -u root -l can be used to recheck it the entries have been injected correctly.

You can also add them to /etc/crontab, but it is not recommended, since it does no syntax check there and it actually there to implement the /etc/cron.* folders only. Check that it would require to add the user (root) before the actual command as well, as can be seen in the other entries.
koyut
Posts: 4
Joined: Mon Feb 13, 2017 3:41 am

Re: Configuring crontab and logs.

Post by koyut »

Running crontab -u root -l shows that it is there. Redid the lines using crontab -u root -e to be sure.

Thank you for pointing out journalctl. I will do some tests and see why if it gets logged.
benjmanable
Posts: 4
Joined: Wed Jun 26, 2019 11:09 am

Re: Configuring crontab and logs.

Post by benjmanable »

Worth Mentioning also that you probably had ramlog installed instead of syslog.

you can change this using the dietpi-software script. You will then find the logs in /var/log/syslog
User avatar
MichaIng
Site Admin
Posts: 2295
Joined: Sat Nov 18, 2017 6:21 pm

Re: Configuring crontab and logs.

Post by MichaIng »

I would not install rsyslog anymore. It is simply an unnecessary overhead (IMO) and we're going to remove it from DietPi-Software as well. Of course it can always be installed manually via APT, but only benefit is that the system logs are simple test files. But since file system is ext4 anyway, Windows is still unable to read them and all external Linux systems can read from remote journal files as well via journalctl.

However systemd-journald (journalctl) is present and main logging daemon anyway. If boot persistent logs are required, simply do:
mkdir /var/log/journal

That way journalctl will preserve logs from last boot sessions as well :).
jhorv
Posts: 10
Joined: Thu May 02, 2019 9:03 pm

Re: Configuring crontab and logs.

Post by jhorv »

I was planning on installing rsyslog when I came across this post. The reason I wanted to use rsyslog was because I would like to have logs from other networked devices sent to my DietPi. Looking into systemd-journal, I saw what appears to be a separate systemd-journal-remote.service. Does this already exist on DietPi or will have to install this separately?
User avatar
MichaIng
Site Admin
Posts: 2295
Joined: Sat Nov 18, 2017 6:21 pm

Re: Configuring crontab and logs.

Post by MichaIng »

@jhorv
This depends on the systemd version, hence Stretch vs Buster, not sure if this is new or exist for long already. Easy to check:
systemctl status systemd-journal-remote
In case:
systemctl enable --now systemd-journal-remote
to start it.
Post Reply