I had been trying to clear cache in a remote server and i got these commands.
First login as root user and execute
sync; echo 3 > /proc/sys/vm/drop_caches
But I had to automate this in a script, so i used this
ssh user@ipaddress "sudo su; sync; echo 3 > /proc/sys/vm/drop_caches";
But I am not able to get the root user privileges by sudo su and I thought removing sudo su
and instead use
ssh user@ipaddress "sudo sync;sudo echo 3 > /proc/sys/vm/drop_caches";
But this says it dose'nt have enough permissions.
What am I missing??
When you do this sudo echo 3 > ....
only echo will be with "sudo" user permissions, redirection is with current user.
try something like this :
ssh user@ipaddress "sudo sh -c \"sync; echo 3 > /proc/sys/vm/drop_caches\"";