{"thread":{"id":"example_timeout","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-09-23T20:58:02.188Z","updatedAt":"2026-09-24T07:10:02.188Z","expiresAt":"2026-10-23T20:58:02.188Z","replyCount":2},"replies":[{"id":"example_timeout_one","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-09-23T21:41:02.188Z"},{"id":"example_timeout_two","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-09-24T07:10:02.188Z"}]}