2

I was looking for some sort of process that is lagging my device. While searching I found that cron is running. If I understand this correctly then cron is needed to run serials of command at a dedicated time. Should I kill it or leave it? What will happen if I stop the cron?

0

5 Answers 5

16

In Unix/Linux systems, lots of OS background tasks are run as cron jobs. To see what won't run if you stop the cron daemon, type these commands:

ls -la /etc/cron.hourly 
ls -la /etc/cron.daily 
ls -la /etc/cron.weekly 

If you really know what you are doing, and you are quite sure you can deal with the consequences, only then shut down cron.

Here are my Raspbian Buster system daily tasks:

-rwxr-xr-x   1 root root   539 Tue Apr 02 2019 22:13:44 apache2
-rwxr-xr-x   1 root root  1478 Tue May 28 2019 15:40:29 apt-compat
-rwxr-xr-x   1 root root   314 Wed Feb 13 2019 17:40:39 aptitude
-rwxr-xr-x   1 root root    77 Sat Feb 16 2019 11:10:23 apt-show-versions
-rwxr-xr-x   1 root root   355 Fri Dec 29 2017 09:02:08 bsdmainutils
-rwxr-xr-x   1 root root  1187 Fri Apr 19 2019 03:14:13 dpkg
-rwxr-xr-x   1 root root  4128 Sat Jul 20 2019 12:35:58 exim4-base
-rwxr-xr-x   1 root root   377 Tue Aug 28 2018 23:21:11 logrotate
-rwxr-xr-x   1 root root  1123 Sun Feb 10 2019 12:11:20 man-db
-rwxr-xr-x   1 root root  1403 Thu Mar 21 2019 22:42:36 ntp
-rwxr-xr-x   1 root root   249 Wed Sep 27 2017 17:45:23 passwd
-rw-r--r--   1 root root   102 Sun Jun 23 2019 18:49:01 .placeholder
-rwxr-xr-x   1 root root   383 Sat Mar 30 2019 17:10:38 samba
-rwxr-xr-x   1 root root   441 Sat Apr 06 2019 08:18:26 sysstat

Also you can see in your system log what cron has been doing for root by doing this:

cat /var/log/syslog | grep CRON | grep root

10

cron runs tasks (system or user chosen) which need to be run at regular intervals.

By itself it uses negligible resources.

I suggest you leave cron alone.

5

Cron is actually very useful. Say you wanted to run a program once a day, then cron is your friend. You can schedule to run a program at any time during the day. I would definitely leave it on your pi. ;)

0
2

Cron is a lightweight process that doesn't use a lot of resources by itself. Plus many other things assume cron is there and working. Leave it there.

Consider installing atop for diagnostics. When the atop service is running, it periodically logs the machine's state to a file for later debugging.

I think atop defaults to every 10 minutes, but you could drop this significantly to help identify what processes are consuming CPU/IO/memory by stepping-through some top-like screens.

From https://www.linuxlinks.com/atop/
from https://www.linuxlinks.com/atop/

0

One of the scripts, which cron.daily executes is logrotate. Logrotate does archive system logs and deletes the old ones. If you disable cron, log files will eat all space on SD card. In Raspbian Buster logrotate is now driven by systemd daemon, so logrotate and few other cron scripts do not make trouble to disable cron.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.