1

I have a 30+ scripts that are run by the crontab at certain intervals, varying from every 30 minutes to once a month. I would like to know if I can see how much drain they cause when they are running?

Q: Is there a way of seeing the CPU usage/drainage caused by the scripts running by the crontab?

Tried: So far the use of the top command, which lists everthing and not specifically the crontab scripts.

0
ps -o user,uid,pid,pcpu,pmem,tty,command --sort=-pcpu $(pidof chrome)
    USER       UID   PID %CPU %MEM TT       COMMAND
    gv        1000  1874  5.4  5.4 ?        /opt/google/chrome/chrome
    gv        1000  1919  4.9  3.8 ?        /opt/google/chrome/chrome --type=gpu-process --channel=1874.0.533630227 --mojo-application
    gv        1000  3327  3.3 11.6 ?        /opt/google/chrome/chrome --type=renderer --touch-events=enabled --enable-features=BlockSm
    gv        1000  3036  2.7  5.6 ?        /opt/google/chrome/chrome --type=renderer --touch-events=enabled --enable-features=BlockSm
    gv        1000  3681  2.2  3.7 ?        /opt/google/chrome/chrome --type=renderer --touch-events=enabled --enable-features=BlockSm
    gv        1000  1967  1.1  4.7 ?        /opt/google/chrome/chrome --type=renderer --touch-events=enabled --enable-features=BlockSm
    gv        1000  4376  0.6  2.7 ?        /opt/google/chrome/chrome --type=renderer --touch-events=enabled --enable-features=BlockSm
    gv        1000  1991  0.1  2.2 ?        /opt/google/chrome/chrome --type=renderer --touch-events=enabled --enable-features=BlockSm
    gv        1000  2356  0.1  2.4 ?        /opt/google/chrome/chrome --type=renderer --touch-events=enabled --enable-features=BlockSm
    gv        1000  1885  0.0  1.1 ?        /opt/google/chrome/chrome --type=zygote
    gv        1000  1891  0.0  0.2 ?        /opt/google/chrome/chrome --type=zygote
    gv        1000  1921  0.0  0.3 ?        /opt/google/chrome/chrome --type=gpu-broker
    gv        1000  1971  0.0  1.6 ?        /opt/google/chrome/chrome --type=renderer --touch-events=enabled --enable-features=BlockSm
    gv        1000  1979  0.0  1.6 ?        /opt/google/chrome/chrome --type=renderer --touch-events=enabled --enable-features=BlockSm
    gv        1000  1988  0.0  1.8 ?        /opt/google/chrome/chrome --type=renderer --touch-events=enabled --enable-features=BlockSm
    gv        1000  1996  0.0  1.7 ?        /opt/google/chrome/chrome --type=renderer --touch-events=enabled --enable-features=BlockSm

Replace chrome with your script's name. Use comm instead of command so COMMAND will be printed in short description. For more options see man ps.

Also check this post: Show top five CPU consuming processes with `ps`

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.