Bleala / Vdirsyncer-DOCKERIZED

Vdirsyncer - sync calendars and addressbooks between servers and the local filesystem. DOCKERIZED!
31 stars 6 forks source link

Strange cron error #3

Closed DjSni closed 2 years ago

DjSni commented 2 years ago

Hi,

good work, but I have a strange error, every time I restart the container the cron entry is rewritten. So my crontab now looks like this:

# do daily/weekly/monthly maintenance
# min   hour    day     month   weekday command
*/15    *       *       *       *       run-parts /etc/periodic/15min
0       *       *       *       *       run-parts /etc/periodic/hourly
0       2       *       *       *       run-parts /etc/periodic/daily
0       3       *       *       6       run-parts /etc/periodic/weekly
0       5       1       *       *       run-parts /etc/periodic/monthly

12,42 0,1,7-23 * * * yes | vdirsyncer discover && vdirsyncer metasync && vdirsyncer sync
12,42 0,1,7-23 * * * yes | vdirsyncer discover && vdirsyncer metasync && vdirsyncer sync
12,42 0,1,7-23 * * * yes | vdirsyncer discover && vdirsyncer metasync && vdirsyncer sync
12,42 0,1,7-23 * * * yes | vdirsyncer discover && vdirsyncer metasync && vdirsyncer sync
12,42 0,1,7-23 * * * yes | vdirsyncer discover && vdirsyncer metasync && vdirsyncer sync
12,42 0,1,7-23 * * * yes | vdirsyncer discover && vdirsyncer metasync && vdirsyncer sync
12,42 0,1,7-23 * * * yes | vdirsyncer discover && vdirsyncer metasync && vdirsyncer sync
12,42 0,1,7-23 * * * yes | vdirsyncer discover && vdirsyncer metasync && vdirsyncer sync

greetings

Bleala commented 2 years ago

Hello,

i'll give it a look, maybe i can reproduce that bug, looked at my crontab and everything was fine.

Will tell you, when i found the problem!

Greetings

nifri commented 2 years ago

I have the same issue. Right now this leads to multiple threads being started at the same time and some thread conflicts as the databases are locked.

I use CRON_TIME: /15 *

My /etc/crontabs/root file looks like this:

~ # cat /etc/crontabs/root                                                                                                                                                    
# do daily/weekly/monthly maintenance                                                                                                                                         
# min   hour    day     month   weekday command                                                                                                                               
*/15    *       *       *       *       run-parts /etc/periodic/15min                                                                                                         
0       *       *       *       *       run-parts /etc/periodic/hourly                                                                                                        
0       2       *       *       *       run-parts /etc/periodic/daily                                                                                                         
0       3       *       *       6       run-parts /etc/periodic/weekly                                                                                                        
0       5       1       *       *       run-parts /etc/periodic/monthly                                                                                                       

*/15 * * * * yes | vdirsyncer discover && vdirsyncer metasync && vdirsyncer sync                                                                                              
*/15 * * * * yes | vdirsyncer discover && vdirsyncer metasync && vdirsyncer sync                                                                                              
*/15 * * * * yes | vdirsyncer discover && vdirsyncer metasync && vdirsyncer sync                                                                                              
*/15 * * * * yes | vdirsyncer discover && vdirsyncer metasync && vdirsyncer sync

I looked at the sync.sh script. On startup you are appending (using ">>") to the /etc/crontabs/root file. So every time the container is restarted a new line is appended.

As the container state is persisted upon restarts this leads to the described behavior. Only terminating the container and recreating it afterwards would destroy the state.

I think the easy and sufficient fix is to use ">". This will remove all the default entries in the beginning (with the /etc/periodic/...) setup. But as the subfolders in /etc/periodic/ are empty everything will work correctly.

If you want to do it "by the book" you could make a copy of the vanilla /etc/crontabs/root file in the image, copy it over via sync.sh to /etc/crontabs and then append the line. But in my view this is overkill.

PS: Thanks for this very useful container!

Bleala commented 2 years ago

@nifri Thanks for that hint, i didn't find a solution so far, because i always recreate the container^^.

I'll change that and upload a new image.

Will tell you guys, when everythings ready! :)

Bleala commented 2 years ago

@DjSni @nifri Problem is solved with release 2.2.1 👍 https://github.com/Bleala/Vdirsyncer-DOCKERIZED/releases/tag/2.2.1

Did it "by the book" as you said, because i was bored and wanted a clean script :D

Hope this solves the problem for you too!

I'll close that issue.

nifri commented 2 years ago

Looking good. I pulled the new image and it works correctly now. Thanks for the speedy fix!