I am trying to implement a daily task that would permit me to extract by dbaccess in my informix database a records from several remote aix server and a script .sh would copy results from the remote to my server. All this have to be executed daily by a crontab in my aix server. When I am testing the scripts all is okay buy at the time that crontab has to execute the script i have in my error log file a message "/home/ope_for.sh: dbaccess: not found". note: /home is the path where the script .sh is located, ope_for is my script my script contain this line: dbaccess base ope_for_new (where my base is my database, and ope_for_new is my sql query)
If the script is initiated by the crontab of an Informix user (with the appropriate rights and settings) you forgot to set the Informix environment variables explicitly in the script. A crontab job is namely started without the environment variables that are common for a loginshell of the user.
I pleased you to tell me which are crontab variables environment to be set up in my script so that i have right result.
This is my crontab: 30 16 * * * /home/ope_for.sh "everyday at 4'30mn the crontab launch the script ope_for.sh which it self launch dbaccess my_database and execute the query ope_for_new
The envvars have nothing to do with crontab but everythingh with the Informix environment. Check out which way a loginshell of the user for whom crontab is configured receives it's Informix envvars upon initiation. Usually it's done somewhere in the .profile or somewhere else in the shell init procedure by sourcing another scriptfile with a line like this
The sourcefile can have any name so check out every file that's sourced with the dot operator at the beginning of the line.
It's also possible that the variables are set manually in the .profile itself. In any case the INFORMIXDIR, INFORMIXSERVER and ONCONFIG variables should be set.
I am little confuse about the location of the envvars on informix in .profile. Please i want to know where and how to set these informix environment INFORMIXDIR, INFORMIXSERVER and ONCONFIG. Look this syntax
Set in the script that's run by crontab the necessary variables for connecting with the Informix engine. In my situation these variables are set in a file that's sourced into the .profile of Informix users and also into the DB scripts run by crontabs. For our IDS 10.00.UC6E these variables are:
I just try to set up envionment variables as follow
dbaccess server_live ope_for
but i am still having an error message in the error log file
/home/ope_for.sh: dbaccess: not found.
The fact i am not understanding is that when I launch the the script on command line i have no problem but i want the system to do it because I need to do it a dozen every 6 hours.
Thanks for your contribution
That's what I said: when a shell is started through crontab the regular environment variables aren't loaded so you have tot do that manually.
Try to find the location of the dbaccess program with:
$ which dbaccess
This should be in $INFORMIXDIR/bin. The $INFORMIXDIR value is decided during server installation and is usually NOT /home/informix! Check the environment of your interactive shell!!!
Then append this directory to the PATH variable with:
Write this in the script that's executed by crontab.
It looks like you are trying to connect to a database that either locally is not known, or remotely does not have permissions for your user.
Locally you must define the remote hostname in DNS (or the local /etc/hosts file) and also the remote instance in the sqlhosts file. Test this by trying to connect to the remote instance using dbaccess.
Remotely the username you are connecting as must exist, and be trusted in the database with connect, select etc. permissions.