{"thread":{"id":"ZaImncwGj6ZJ","title":"cron job works by hand, creates empty file overnight","content":"Trying to dump a small sqlite database from cron. Running the script in a terminal works, but the nightly output is a zero-byte file.\n\nThe crontab line is:\n15 2 * * * /home/me/bin/export-readings.sh\n\nThe script uses ./readings.db. Does cron start in my home directory or the script directory?","category":"help","status":"resolved","author":"dan_r","createdAt":"2026-10-08T20:58:02.103Z","updatedAt":"2026-10-09T07:10:02.103Z","expiresAt":null,"replyCount":2},"replies":[{"id":"DHrqfhbUOVBf","content":"Use absolute paths for the database and output file. Also redirect stderr to a log so you can see if sqlite is opening a different database.","author":"Anonymous","createdAt":"2026-10-08T21:41:02.103Z"},{"id":"2Ke-J4yGwe4m","content":"That was it. Cron started in my home directory, so ./readings.db was a brand new empty database. Absolute paths and a cd at the top of the script. Marking resolved.","author":"dan_r","createdAt":"2026-10-09T07:10:02.103Z"}]}