freedev / macosx-script-boot-shutdown

This project is useful to execute a shell script during Mac OS X boot or shutdown.
Apache License 2.0
78 stars 23 forks source link

regular CPU spike #6

Closed Tormen closed 4 years ago

Tormen commented 4 years ago

Hi,

thanks a lot for the script. I use it :)

Buuut I noticed (and hunted down) regular CPU spikes caused by fseventd (and mdstore). Turns out it was the "endless loop" in your script using tail on /dev/null that caused them.

I replaced the tail... and the wait $! with sleep 36500d and thats much better. Granted: If I won't reboot my laptop in 100 years I have a problem. But I can live with that ;)

Voilà. I thought, maybe you wanna know :)

Thanks again anyways!!

PS: I picked the solution from here: https://superuser.com/questions/681954/is-there-a-command-in-linux-which-waits-till-it-will-be-terminated I was sure that sleep will be efficient.... maybe read is the same... did not try this one.

freedev commented 4 years ago

Hi @Tormen thanks for sharing the info and btw it's pretty strange the problem you had.

Tormen commented 4 years ago

Hi @freedev , yeah I know. I used your tail based implementation because I thought it's safe. But I am 100% certain that the above was the cause and the solution, as I had killed one by one all user programs, then all (non-apple) launchAgents and (non-apple) launchDaemons (from the user and finally form the system...) and in the end it was only this init script and little snitch daemon...

And it was really like clockwork: Every few seconds spike of fseventd (together with mdstore) because of the mdstore I had thought of Mail or spotlight or something...

But the moment I stoped the launchDaemon, bam the spikes stopped and vice-versa.

Cheers,

Tormen

PS: For the record: I am using MacOS Catalina 10.15.4 (19E266).

freedev commented 4 years ago

Honestly I haven't the time to double check the problem in my env. And I still use the original version of the script every day. When you can, I'm just curios to see you your version.