cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with the dbmcli-call in a cronjob

Former Member
0 Kudos

I have a problem with a cronjob. When I started the script "recover_dbmcli.sh" with the user-id p01adm, the script running succesfully.

But when i started the same script with the crontab, the script started; but the dbmcli-command was not running

The crontab was edited with the same user-id p01adm.

simple example:

p01adm: crontab -e

30 13 * * * touch /tmp/recover_cron_ok ; cd /home/p01adm/ ; ./recover_dbmcli.sh ;

-


Script recover_dbmcli.sh:

#!/bin/bash

dbmcli -U c -i /home/p01adm/restore2.txt

exit 0

-


restore2.txt:

db_admin

Accepted Solutions (1)

Accepted Solutions (1)

lbreddemann
Active Contributor
0 Kudos

> Script recover_dbmcli.sh:

>

> #!/bin/bash

> dbmcli -U c -i /home/p01adm/restore2.txt

> exit 0

Hmm.. at least the last line would be a bug to me... this covers all errors and nobody ever will notice.

> restore2.txt:

>

> db_admin

Hmm... without any loginformation I'd just assume that the user account under which the cron daemon runs lacks permssions or something like that.

How about using the -l <logfile name> switch or redirecting the output to a file ( >> filename) ?

regards,

Lars

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Lars,

thanks for your fast answer. I redirecting the output to a file , but this file is empty.

#!/bin/bash

dbmcli -U c -i /home/p01adm/restore2.txt >> /tmp/log.txt

exit 0

-rw-rr 1 p01adm sapsys 0 2010-07-29 15:10 recover_cron_ok

-rw-rr 1 p01adm sapsys 0 2010-07-29 15:10 log.txt

best regards

volker

markus_doehr2
Active Contributor
0 Kudos

> thanks for your fast answer. I redirecting the output to a file , but this file is empty.

Please check the cron logfile.

Without giving full PATHs the system does not find dbmcli.

Markus

Former Member
0 Kudos

Hi Markus,

when i implemented your commands in my script, its worked.

Thank you for your help. I'm happy.

markus_doehr2
Active Contributor
0 Kudos

> I have a problem with a cronjob. When I started the script "recover_dbmcli.sh" with the user-id p01adm, the script running succesfully.

> But when i started the same script with the crontab, the script started; but the dbmcli-command was not running

Did you explicitly source the environment? Cron does not do that automatically. So you'd have to start your script such as

#!/bin/csh
#
source $HOME/cshrc
source $HOME/.dbenv_<hostname>.csh

etc.

Markus