Here's my source:
#!/bin/bash echo "Running script to free general cached memory!" echo ""; echo "Script must be run as root!"; echo ""; echo "Clearing swap!"; swapoff -a && swapon -a; echo ""; echo "Clear inodes and page file!"; echo 1 > /proc/sys/vm/drop_caches; echo "";
It clears caches and stuff, and it echoes that it needs to be run as root in the terminal. I basically just want the script to cease running if it detects it's not being executed as root.
"Running script to free general cached memory!" "Warning: script must be run as root or with elevated privileges!" "Error: script not running as root or with sudo! Exiting..."
If run with elevated privileges, it just runs as normal. Any ideas? Thanks!