Executing shell in crontab cannot find db2 database

AIX UNIX

execute first

crontab -e after editing

re-execute

crontab -l to view,

If you execute crontab -l first, an error will be reported,

 

report an error

SQL1013N  The database alias name or database name "DBNAME" could not be found.

 

Solution

Add the execution .profile to the script and add "environment variables"

. /home/test/.profile

Note that there is a space in front of

 

Add content to .profile

PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.

 

export PATH

 

if [ -s "$MAIL" ]           # This is at Shell startup.  In normal

then echo "$MAILMSG"        # operation, the Shell checks

fi                          # periodically.

if [ -f /home/db2inst1/sqllib/db2profile ]; then

    . /home/db2inst1/sqllib/db2profile

be

 

can be added to the script

id #View current user

whoami #View current user

pwd #View the current path

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326400783&siteId=291194637