Linux terminal app sync works fine in-app, not working via scheduled cron job

I just recently installed the terminal version of the app via nodejs/NPM, and configured it to sync via Dropbox. When I’m running the app, everything’s working great–Dropbox syncing is working to/from the terminal app as designed.

But my crontab scheduled task to sync when Joplin isn’t running doesn’t appear to be working or not as I’d expect it. I’ve got an entry like this in crontab:
*/10 * * * * /home/myusername/.joplin-bin/bin/joplin sync

EDIT: One thing I failed to mention in original post that may be relevant is that was adding this to the sudo crontab, not my username’s crontab. I figured that’d still work since I specified the absolute path of my user’s Joplin install folder.

Running that command outside cron works, and I can see the typical Joplin messages about fetching or creating remote items. Additionally, when I let the cron task run, I can see via top when the node process and joplin commands run, consume some CPU, and then finish. And in the cron.log file, I see the command runs with no obvious error or anything.

But when I then launch the Joplin app, the files/changes I would’ve expected to sync are not there until it runs for a minute and completes its own in-app sync (or I run the :sync command to initiate it).

Does anyone have some ideas on how I can troubleshoot this? Are there some Joplin logs that might give some clues? Thank you!

Whoops, so I guess I didn’t understand all I needed to understand with regard to cron. So I needed to either create a cron job using my own user account or, if I was determined to use sudo crontab, then I needed to specify the username to run the task with. This is what I ended up doing so my crontab is:
*/5 * * * * su MyUsername -c "joplin sync"
And now it works fine!

1 Like