Go to file
Adler Neves 0fb2322c31
continuous-integration/drone/push Build is passing Details
docs: added readme
2022-11-20 16:02:03 -03:00
src first commit 2022-11-20 15:16:34 -03:00
.drone.yml ci: added 2022-11-20 15:25:52 -03:00
.gitignore first commit 2022-11-20 15:16:34 -03:00
Cargo.lock first commit 2022-11-20 15:16:34 -03:00
Cargo.toml first commit 2022-11-20 15:16:34 -03:00
README.md docs: added readme 2022-11-20 16:02:03 -03:00

README.md

free-memory-cmd

Runs a command if memory usage exceeds a certain threshould.

Memory usage can be RAM, SWAP, or both combined.

Usage

free-memory-cmd <RAM|SWAP|COMB> <percentage> <command>

Examples

  • Reboot if using over 80% of SWAP.
    free-memory-cmd SWAP 80 reboot
    
  • Check if RAM usage is over 60% within a shell script
    free-memory-cmd RAM 60 './my-memory-saving-measures.sh'
    
  • Check if RAM usage is over 60% within a shell script
    if ! free-memory-cmd RAM 60 false ; then
        # do your "over 60% RAM usage" thing here
    fi
    

Crontab

It's perfectly possible to write jobs like:

* * * * * free-memory-cmd COMB 50 reboot