1

I want to delete old database backups and log the output to a file. I am using the following code I found here: deleting old files using crontab (And I added a verbose option to the rm command)

0 3 * * * find $HOME/db_backups -name "db_name*.sql" -mtime +30 -exec rm -v {} \; >> $HOME/db_backups/purge.log 2>&1

The problem is that the output gets logged on one line:

removed '/home/$user/db_backups/db_name_20180525214726.sql'removed '/home/$user/db_backups/db_name_20180525224726.sql'removed '/home/$user/db_backups/db_name_20180525234726.sql'

Is it possible to have each of the entries logged on a newline? Like so:

removed '/home/$user/db_backups/db_name_20180525214726.sql'
removed '/home/$user/db_backups/db_name_20180525224726.sql'
removed '/home/$user/db_backups/db_name_20180525234726.sql'
removed '/home/$user/db_backups/db_name_20180525244726.sql'

I have tried modifying the command with a /n to create a newline, but -exec tries to interpret it and I get errors. I'm not sure how to pass that option in properly.

Any help?

Quorong
  • 21
  • 4

1 Answers1

1

Nevermind folks. Notepad is just that bad of an editor. Log files look good on Notepad++/Sublime Text.

Quorong
  • 21
  • 4