I'm having some issues with a command that only seems to work when run as a regular user:

find /mnt/data* -mmin +119 -name '*.adsr' -type f -delete 2>&1 | tee -a /log/rsynclog.txt

If I use the command as a regular user, I get permission errors in the log. Once I'm root the command doesn't append to my log. This is one of the commands that are running in my cron.hourly.

Does this mean it will log only if I get errors? Is there something I can change so a successful delete shows up in my log as well?

  • Are yiu sure thaty it is to to being executes as root? Because a known issue is commands failing when being executes by cron (as any user) because the paths and the rest of the environment is often different. You can test that by simply running it as root (uid 0). Regardless of that, did you mean any folder under mnt whose name starts with data?
    – Hennes
    May 29, 2018 at 13:59
  • What filesystems are mounted under /mnt/data?
    – user1686
    May 29, 2018 at 14:00
  • I tested running the command in the terminal as root, it doesnt run. It does run however as reg user in terminal ( Filesystem of data is ext4 )
    – Rickert
    May 29, 2018 at 14:01
  • Interesting. Then it probably is not a run as root (command 1), followed by | tee now runs as regular user. Which was my other idea.
    – Hennes
    May 29, 2018 at 14:02
  • i meant everything under data, the command has worked before but i recently added the | tee command because i need to log everything in my auto-backup cron
    – Rickert
    May 29, 2018 at 14:09

1 Answer 1


tee -a doesn't do anything unless I run it as regular user, then it gives me a ton of permission denied errors in my log

Your command seems fine. It just doesn't generate output because -delete suppresses the default -print output of find; and when running as root, it doesn't hit any permission denied.

If you want to log files being deleted, use -print explicitly:

find … -delete -print 2>&1 | tee -a …

Note -delete -print is slightly different than -print -delete. The former will print only if removal succeeded; the latter will print regardless. In a case of unsuccessful -delete you get a message to strerr which you log as well, so -delete -print should be just fine for you.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.