Issue
I'm new in Ubuntu and programming. I'm testing a program that I found on github, to download and import OSM data into postgis. It works when I run it from terminal (url and name are fake):
make all NAME=dbname URL='http://myurl'
using postgres user.
Now I need to run this command every day. So I wrote that script:
#!/bin/bash
# go to the directory with Makefile
cd /PCuserhome/directory/to/Makefile/
# run Makefile
make all NAME=dbname URL='http://myurl'
and it works when i run it from terminal.
So I have added it to crontab (of postgres user) in this way:
0,15,30,45 * * * * /PCuserhome/myscript.sh
It create the db but probably fail in running osmosis selection (Osmosis is in the path for all users). Any idea to solve this? Thank you!
Solution
crontab commands are executed only with minimal environment variables, i.e.
PATH=/usr/bin:/bin
(on debian anyway),
so if you are relying on programs that are in your $PATH
, it will fail.
Consider specifying an absolute path to the osmosis program wherever it's called from.
Alternatively you can change $PATH
itself in your script
export PATH="/my/bin:$PATH"
p.s.: you can check the environment by adding a simple cron job
* * * * * env > /tmp/env.txt
Answered By - Peter Uhnak Answer Checked By - Robin (WPSolving Admin)