Troubles with logging and Cron jobs Topic is solved

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
drool
Posts: 14
Joined: Sun Jan 26, 2020 5:44 pm

Troubles with logging and Cron jobs

Post by drool »

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.
User avatar
Joulinar
Posts: 2586
Joined: Sat Nov 16, 2019 12:49 am

Re: Troubles with logging and Cron jobs

Post by Joulinar »

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

Code: Select all

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
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
drool
Posts: 14
Joined: Sun Jan 26, 2020 5:44 pm

Re: Troubles with logging and Cron jobs

Post by drool »

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.
User avatar
Joulinar
Posts: 2586
Joined: Sat Nov 16, 2019 12:49 am

Re: Troubles with logging and Cron jobs

Post by Joulinar »

Hi,

can you let me know where did you changed the logging exactly?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
drool
Posts: 14
Joined: Sun Jan 26, 2020 5:44 pm

Re: Troubles with logging and Cron jobs

Post by drool »

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.
drool
Posts: 14
Joined: Sun Jan 26, 2020 5:44 pm

Re: Troubles with logging and Cron jobs

Post by drool »

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.
User avatar
Joulinar
Posts: 2586
Joined: Sat Nov 16, 2019 12:49 am

Re: Troubles with logging and Cron jobs

Post by Joulinar »

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. :)
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
drool
Posts: 14
Joined: Sun Jan 26, 2020 5:44 pm

Re: Troubles with logging and Cron jobs

Post by drool »

Yes, I was about to write that maybe rsyslog was preinstalled along with some other package.
Thanks for all the help. Really appreciate it.
User avatar
Joulinar
Posts: 2586
Joined: Sat Nov 16, 2019 12:49 am

Re: Troubles with logging and Cron jobs

Post by Joulinar »

yw. Maybe option 3 FULL should be your choice if you like to stay with the logs and keep them.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
drool
Posts: 14
Joined: Sun Jan 26, 2020 5:44 pm

Re: Troubles with logging and Cron jobs

Post by drool »

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.
Post Reply