0

I'm using Crontab to start a python file with the code:

@reboot sleep 5 && Sudo python3 /home/pi/file.py

The file uses the internet to retrieve some JSON data and display it on a screen

However it doesn't take 5 seconds to start the file as stated in the crontab line, it takes much longer.

After some digging, I found out the following:

enter image description here

Can I disable any of these to make it faster?

1

I'm using Crontab to....

A simpler (at least WRT solving the problem) approach would be to start it via systemd, giving you more control over what point in the boot process it happens. You may not get five seconds, but you should be able to get less than 10 -- this is a bit contingent on what you mean by "display" some(thing from) JSON. If you need the GUI, that takes time.

I notice your fsck seems to take a long time to start; it could be that this implies the system was not shut down properly, otherwise it means it took 16 seconds to get there, and you won't be able to schedule something before that. systemd-analyze blame is actually more informative in that context.

Here's a systemd-analyze critical-chain from a Pi 4:

multi-user.target @8.715s
└─exim4.service @8.083s +630ms
  └─remote-fs.target @8.032s
    └─remote-fs-pre.target @8.031s
      └─nfs-server.service @6.766s +1.261s
        └─nfs-mountd.service @5.407s +1.104s
          └─network.target @5.399s
            └─networking.service @5.089s +308ms
              └─local-fs.target @5.068s
                └─var-lib-lxcfs.mount @6.506s
                  └─local-fs-pre.target @2.050s
                    └─systemd-tmpfiles-setup-dev.service @1.962s +78ms
                      └─systemd-sysusers.service @1.878s +65ms
                        └─systemd-remount-fs.service @1.552s +306ms
                          └─systemd-fsck-root.service @1.328s +216ms
                            └─fake-hwclock.service @1.189s +129ms
                              └─systemd-journald.socket @1.111s
                                └─system.slice @1.035s
                                  └─-.slice @1.035s

This isn't loading a GUI, and a Pi 4 probably gets this done a 2-3 times faster than a Zero. But notice the fsck starts after ~1.3s. network-service, which you would need, is ready after ~5.4s.

If you have not yet, have a look at man systemd-analyze.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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