Cron to find exec cp and redirect output with time / date per line?
0
votes
2
answers
489
views
I try to setup a
cron
task to run a set of basic shell commands.
I need to look to any files created on the last day, then copy to another folder and generate a log stating, line by line, the date and the time of the file copy operation.
The two shell commands run separately but need to create one and schedule via cron
. When I try to increase the first command (find
) cron
does not execute the task and gives errors. If I run manually, it works.
find /dir/ -type f -mtime -1 -exec cp -v -a --parents "{}" /dir2/ \; >> /dir2/LogsCopiaDBs_$(date +%d-%m-%Y).txt
exec &> >(while read line; do echo "$(date +'%h %d %Hh%Mm%Ss') $line" >> /dir2/LogsCopiaDBs.txt; done;)
Any idea ?
Asked by Edson S Freitas
(1 rep)
Nov 13, 2015, 02:25 PM
Last activity: Mar 17, 2025, 07:28 AM
Last activity: Mar 17, 2025, 07:28 AM