qm guest exec "rm -rf"

jmjosebest

Renowned Member
Jan 16, 2009
192
40
93
Hello,

I want to remove the entire content of /var/log/ inside a VM, I tried with:

Code:
qm guest exec 2745 rm -- '-rf' '/var/log/*'

Code:
pvesh create /nodes/ns1028/qemu/2745/agent/exec --command 'rm' --command '-rf' --command '/var/log/*'

But when I check in the VM, seems nothing has happened.

Any idea?

Thanks!
 
hi,

try like the following using the -- separator:
Code:
qm guest exec 2745 -- rm -rf /var/log/*

hope this helps

edit: just for the record it might not be such a good idea to remove the directory structure from /var/log, so maybe you're better off running something like find /var/log -type f -exec rm -f {} ';'
 
Last edited: