Progrider

Programming discussion

Board index
Help✓ Resolved

cron job works by hand, creates empty file overnight

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. The crontab line is: 15 2 * * * /home/me/bin/export-readings.sh The script uses ./readings.db. Does cron start in my home directory or the script directory?

2 replies

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.
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.

Discussion resolved

This discussion is resolved. Its creator can reopen it to accept more replies.