Simple Bash log backup script
Put /path/to/dir/ in a variable to avoid writing it repeatedly.

Instead of running the command and checking $? after,
you can put the command inside an if.

The script would become shorter, for example:

path=/path/to/dir

if find $path -daystart -type f -mtime 1 -name "*.log" -print | zip $path/"logbackup-$yest.zip" -@
then
    find $path -daystart -type f -mtime 1 -name "*.log" -exec rm -f {} \;
fi


In my tests, it seems that simply dropping -daystart will have the desired effect of matching the right files. For example:

touch -d yesterday a
touch -d '2014-11-19 00:00:00' b
touch -d '2014-11-18 00:00:00' c
touch -d '2 days ago' d
ls -l


Gives:


-rw-r--r-- 1 janos users 0 Nov 19 12:35 a
-rw-r--r-- 1 janos users 0 Nov 19 00:00 b
-rw-r--r-- 1 janos users 0 Nov 18 00:00 c
-rw-r--r-- 1 janos users 0 Nov 18 12:38 d



And then:


$ find . -daystart -mtime 1 -type f
./a
$ find . -mtime 1 -type f
./a
./b