File: //scripts/checkTmp.sh
#!/bin/bash
# Threshold for usage percentage
THRESHOLD=90
# Check the usage of /tmp
USAGE=$(df /tmp | awk 'NR==2 {print $5}' | sed 's/%//')
# If usage is greater than or equal to the threshold
if [ $USAGE -ge $THRESHOLD ]; then
echo "/tmp usage is at $USAGE%. Clearing garbage files..."
# Remove garbage files
rm -rf /tmp/php*
rm -rf /tmp/_MEI*
# Restart the lsws service
echo "Restarting lsws service..."
service lsws restart
curl --location --request POST 'https://marketing.wp.karmanye.in/api/Karmanye/send-message' --header 'Content-Type: application/json; charset=utf-8' --header 'Accept: application/json' --header 'Authorization: Bearer $2b$10$f7yAQHm3Y1eOxs92aiEJ9eohJ0AdUQ2YwXxUARzk3sVLgKIVw0k2q' -d '{ "phone": "919033595842", "message": "*/tmp full '$USAGE'% | Cleared phpgarbage and Restarted Service*"}'
else
echo "/tmp usage is at $USAGE%. No action needed."
fi