Skip to content

Instantly share code, notes, and snippets.

@RPDiep
Last active July 25, 2016 11:59
Show Gist options
  • Save RPDiep/55577709630d4a0bc29a88f80ab36ff4 to your computer and use it in GitHub Desktop.
Save RPDiep/55577709630d4a0bc29a88f80ab36ff4 to your computer and use it in GitHub Desktop.
#!/bin/bash
max_apache_semaphores=20
cur_apache_semaphores=$(ipcs -s | grep -c apache)
apachectl=$(which apache2ctl apachectl 2>/dev/null)
[[ ${cur_apache_semaphores} -ge ${max_apache_semaphores} ]] && {
logger -t $(basename $0) "Cleaning up semaphores for apache"
ipcs -s | awk '/apache/ {print $2}' | xargs -n1 ipcrm -s
${apachectl} restart
}
@RPDiep
Copy link
Author

RPDiep commented Jul 25, 2016

Add as script in /etc/cron.hourly and chmod +x the script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment