Auto emptying of recycle bin not working

  • I'm still getting the problem whereby files don't get removed from the recycle bin automatically after the specified number of days.

    Also, clicking "Empty Now" > "Start" to empty it manually doesn't work, as there's always a lock file:

    mkdir: cannot create directory ‘/run/samba-recycle-ac7daaea-0544-43e5-8123-ba9306e1f5bd.lock’: File exists 

    ERROR: Locking failed, another job is running 

    Done ...

    Deleting the lock file and then doing "Empty Now" > "Start" works, but the lock file from that process obviously persists, preventing the automatic emptying working subsequently.

    From reading the github changelog*, I understood a fix for this issue had been rolled-out in 5.5.17-1 — but I'm using 5.5.22-1 and it's still occurring.


    Thanks in advance for any help.

  • KM0201

    Approved the thread.
  • Seems there are other issues with the script. We can not fix this without your help, so please investigate as much as possible why the script does not run. Without being able to reproduce this issue we can't debug and fix it.

    The sources can be found here:…cron-recyclebin-script.j2 and…oy/samba/40recyclebin.sls

    The scripts generated are /etc/cron.daily/openmediavault-samba-recycle and /var/lib/openmediavault/cron.d/samba-recycle-*.

    Maybe trap "rm -rf ${lockfile}; exit" 0 1 2 5 15 is a problem. But if so, it is a bigger issue that is related to the shell. Another one is problems with cron in combination with trap. Finally, it is not trivial at all.

    Any contribution is welcome.

  • What you can try is to modify the content of [tt]/etc/cron.daily/openmediavault-samba-recycle[/tt] to:


    run-parts --regex='{{ cron_scripts_prefix }}*' {{ scripts_dir }} &>/dev/null


    run-parts --new-session --regex='{{ cron_scripts_prefix }}*' {{ scripts_dir }} &>/dev/null

  • Many thanks for the replies, and my apologies for not having acknowledged them until now.

    I've made the suggested amendment to /etc/cron.daily/openmediavault-samba-recycle

    I note that the file header says: "Do not edit this file, your changes will get lost" — when will it next get overwritten? (I just want to be sure that the amendment persists long enough to be testable.)

  • Does adding --new-session fix the problem?

    I don't know as yet.

    There was a lock file in /run when I just looked (not sure from when) so I deleted that.

    I've set the recycle bin so that deleted files more than 1 day old will be removed.

    I just deleted something, so I will check things again tomorrow and the next day, and then post again.

  • They get overwritten when you modify shared folders or SMB settings.

    Does adding --new-session fix the problem?

    Ok... an update:

    1.) There's a samba-recycle lock file in /run again.

    2.) etc/cron.daily/openmediavault-samba-recycle has been overwritten such that --new-session has gone.

    But I don't know when it got overwritten, so I don't know if it didn't solve the problem or if it wasn't there when the script ran.

    Could I run the script manually and test it that way?

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!