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?
Your discussion
This browser holds the management token for this post.
Save management token
Keep this private. Anyone with the token can resolve or delete this discussion.
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.