Configuring crontab and logs.

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.

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.

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.

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

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 :slight_smile:.

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?

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.