Troubles with logging and Cron jobs

Hi, a new Dietpi user(read as diet pi noob).

Problem 1:
I was on logging #1 and everything was going well. The system was generating /var/log/syslog files as expected. Then to keep cron logs, I switched to logging #2 and now I don’t see /var/log/syslog being generated anymore. Next I switched back to logging #1 and I still don’t see the syslog anymore. Can someone help me setup the logging #2 correctly with syslog working as expected.

Problem 2:
I want to run a script as minutely cron job. The file is located at /etc/cron.minutely/alive.sh. I have enabled minutely cron from Dietpi Cron manager but I don’t see the cron job being execute minutely. I can run the script manually though. The permissions are same as on other Dietpi owned hourly cron jobs.

Hi,
many thanks for your report.

Question 1:
What exactly you like to see in the logs? Anything special you are looking for? You could use journalctl to check what happen on your system.

In general, to get logging enabled, you would need to install rsyslog package

apt-get install rsyslog

this will create /var/log/syslog and /var/log/messages

Question 2:

  1. Files in /etc/cron.*/ are not allowed to have file endings, hence rename abc.sh to abc
  2. Take care it has the shebang #!/bin/bash (or whichever shell works), as those files are not explicitly executed with a specific shell.
  3. Take care it is executable: chmod +x /etc/cron.minutely/abc
  4. Check if it would be executed: run-parts --test /etc/cron.minutely/

Just for reference, as the bid strict rules of run-parts, used to execute the files in those dirs, I link the man page: https://manpages.debian.org/run-parts

Thank you for help, Joulinar.

run-parts reference was a good learning. After the fixes you told for Cron, the job is working well now. So that part is all good.

Regarding the logging, I confirmed by running dpkg -l rsyslog, that rsyslog is not currently installed. As I was seeing my VPN logs in syslog earlier, does it mean it was earlier installed? If yes, why would switching from logging#1 to #2 uninstall the rsyslog package. Just curious, shouldn’t the packages be untouched and just the configuration(how and where the logs are saved) be changed.

Hi,

can you let me know where did you changed the logging exactly?

Hi Joulinar,

I went to the “Diet-pi Software” portal → Changes “Log System” from “DietPi-Ramlog #1” to #2 and couldn’t find /var/log/syslog ever since. I also tried flipping it back to #1, but still no syslog.

I was just playing with the settings again, and I saw the following message when switching between "Log System"s:

│ DietPi-Ramlog #2 has been selected: │
│ - Your choice will be applied when ‘Install Go >> Start installation’ is selected. │
│ - Logrotate, Rsyslog installations will be automatically uninstalled.

Not sure, why dietpi needs to uninstall rsyslog or even logrotate at this point. Shouldn’t the only difference between the logsystem #1 and #2 be that the older rotated logs being stored on persistent storage(once at the end of the hour) rather than being discarded hourly.

Hi,

ok good. Usually rsyslog is not part of the standard image and will be installed if your chose option 3 FULL only.

So probably it was installed by another software before. However, I guess the moment you switched to #2 it was un-installed. Solution would be to go to option 3 FULL or go to install it yourselves. :slight_smile:

Yes, I was about to write that maybe rsyslog was preinstalled along with some other package.
Thanks for all the help. Really appreciate it.

yw. Maybe option 3 FULL should be your choice if you like to stay with the logs and keep them.

Thank you again, Joulinar. I am hoping to keep using #2 to save sd card wear but also to persist to storage, hourly. Also to confirm, after installing rysylog, everything was working as expected.