-
-
Save linuxmalaysia/ad31fe4dbfe76e9e8674d88ad9f0bcd5 to your computer and use it in GitHub Desktop.
| # uptime report every 1 minutes everyday | |
| */10 * * * * root uptime | logger -t uptime > /dev/null | |
| */10 * * * * root free -h | head -2 | tail -1 | logger -t free > /dev/null |
Suggestion from ChatGPT
Certainly! Your crontab entry looks good for monitoring uptime and free memory, but there are a couple of improvements that can be made for better readability and efficiency. Here's an updated version:
# Uptime report every 10 minutes every day
*/10 * * * * root /bin/bash -l -c 'uptime | logger -t uptime' > /dev/null
# Free memory report every 10 minutes every day
*/10 * * * * root /bin/bash -l -c 'free -h | awk "/Mem/{print}" | logger -t free' > /dev/nullChanges made:
-
Added
/bin/bash -l -cbefore the commands to ensure that the commands are executed in a login shell environment. This helps in loading the user's environment variables, which might be necessary for the proper execution of some commands. -
Used
awkto filter the output of thefreecommand to only include the line with "Mem". This makes the command more specific and avoids potential issues if the output format changes.
Feel free to adjust the frequency (*/10 * * * *) based on your monitoring needs. The provided version ensures that the commands are executed every 10 minutes.
Uh oh!
There was an error while loading. Please reload this page.