I am running DietPi on a RPI in my network with some docker containers on it.

I recently got the idea to switch off containers when not needed, e.g. during the night, since this will allow my hard drive to switch off and saves a bit of energy.

I do not recall how I found out, but for some reason what I did was to just edit the /etc/crontab file that DietPi has with sudo. Worked like a charm, I had my containers stopped and started just as specified.

But then I wanted to make some changes, change some times, add some other stuff. I did it the same way, edit the /etc/crontab file with sudo. Didn't work, none of my new additions worked.

I searched online and figured out the better way to do this is use the command "crontab -e", edit stuff there, then also check with "crontab -l" right after. That worked, now my new containers are all behaving as they should.

But how do I now get rid of the stuff I defined in /etc/crontab? I removed it all from that file, saved it, restarted the system, nothing removed these, they are somehow persisting. I know they do because I use a different log file for these and that log file still gets generated now. How can I fix this?

Bonus question about log files, how can I make them more useful in terms of information? Right now they just name the command, not even a timestamp or anything.

Thanks!

you are viewing a single comment's thread
view the rest of the comments
[–] 9 points 12 hours ago* (1 child)

Crontabs can live in different places on different systems, but generally when you run crontab -e you're editing the crontab of the current user, which is generally placed in /var/spool/cron/{username}. If you do sudo crontab -e that edits the crontab/file for root. There can be other files nested in /etc/cron.d, /etc/cron.hourly, /etc/cron.daily et cetera as well.

To find out where those old cronjobs are still defined, you can recursive grep the name of that unique log file you mentioned (if the log file is part of the command in the crontab). grep -r "{unique log file name}" /etc and /var/spool should find it. If the log file name isn't in the command, grep for some other unique string from that cronjob that would stand out amidst everything else in /etc.

To add timestamps to log output, you can pipe it through ts.

  • source
  • hideshow 1 child comment