qm guest exec "rm -rf"

Jan 16, 2009
175
14
38
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!
 

oguz

Proxmox Staff Member
Staff member
Nov 19, 2018
5,032
637
118
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:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!