andreafrancia / trash-cli

Command line interface to the freedesktop.org trashcan.
GNU General Public License v2.0
3.63k stars 177 forks source link

About using cron with this program #262

Open Archie-2021 opened 1 year ago

Archie-2021 commented 1 year ago

Sorry if it is a newbie question, but I am trying to use cron to empty the trash as a test and noticed it is not working because there is a prompt after running the command and I can't find any option in the man page to disable that. So how I can set up a cronjob (possibly an anacron job) with this?

Thank you.

andreafrancia commented 1 year ago

trash-empty can detect if it is working on cron it will not ask any confirmation. If not this would be a bug. In any case you can force the non-interactive mode using the -f flag.

Archie-2021 commented 1 year ago

Thanks for clearifying as I could not find the -f option in documnetation. It is working now with cron as I am testing it, I was using anacron and it didn't work even with the -f flag, still not sure if I am not using anacron correctly or it is another issue.

Archie-2021 commented 1 year ago

I think because anacron runs as root trash-empty applies to the root account. In that case is there a way to specify which user trash to clean? Everything works fine otherwise, It is the only explanation that comes to my mind.

andreafrancia commented 1 year ago

I think because anacron runs as root trash-empty applies to the root account. In that case is there a way to specify which user trash to clean?

I don't know anacron, but to run a command with another user when you are root you can use this command:

sudo -u your-user trash-empty 100
Archie-2021 commented 1 year ago

I think because anacron runs as root trash-empty applies to the root account. In that case is there a way to specify which user trash to clean?

I don't know anacron, but to run a command with another user when you are root you can use this command:

sudo -u your-user trash-empty 100

This one works, the issue was ownership of the process.

Thank you