• Uncategorized

About python-3.x : Systemd-service-taking-a-long-time-to-run

Question Detail

I am having service running as background service in EC2 instance. but it taking a long time to start a new one or restart a service ( refer to image: I reboot EC2, and a service restart at 9:00, but at the 11:32, a service print the first log ).

Here is my service config file in etc/systemd/system:

Description=file scanner ...

ExecStart=/usr/bin/python3 main.py


Please help.

Question Answer

Suggesting to start your python script from command line to test how long it takes:

  /usr/bin/python3 /apps/file-scanner/main.py 

If it takes as long than you need to fix your /apps/file-scanner/main.py and profile it to learn what takes long time. Use standard python3 profiling tools and put many logging message.

It is very possible your /apps/file-scanner/main.py script is consuming most of the memory resources and cpu resources therefore your script takes very long to start.

Also learn to use top command to monitor machine utilization at runtime.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.