I have a bash script which runs a set of php scripts. When it runs it takes an hour and pegs the CPU at 95-99%. This causes our lamp stack (mainly the apache process) problems and our website on the same server starts spitting out timeout or 500 errors.
How can I either:
- Run the bash script and all associated tasks (php scripts which also call the PostgreSQL db) at a low priority so apache, php and db tasks for the web server are always prioritized, OR
- Limit the CPU usage for the script and associated tasks to, e.g. 25% CPU
I’m not sure which is the better solution.
In addition to
nice, looking at limiting CPU time, using
ulimit -t (assuming you are on a *nix platform)
Leave a comment
- SCP transfer only modified files
- How can I automate clearing and resetting a Linux user’s home directory to a default?
- Cron expression that runs every 5 minutes from 1:30 am – 6:00 am [duplicate]
- Understanding redundant power supplies
- Is there a way for administrators to disable users from installing Firefox extensions?