trash-cli icon indicating copy to clipboard operation
trash-cli copied to clipboard

About using cron with this program

Open Archie-2021 opened this issue 3 years ago • 5 comments

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.

Archie-2021 avatar Nov 10 '22 08:11 Archie-2021

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.

andreafrancia avatar Nov 10 '22 18:11 andreafrancia

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 avatar Nov 11 '22 09:11 Archie-2021

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.

Archie-2021 avatar Nov 11 '22 14:11 Archie-2021

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

andreafrancia avatar Nov 12 '22 10:11 andreafrancia

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

Archie-2021 avatar Nov 12 '22 13:11 Archie-2021