Welcome Serena Central users! CLICK HERE
The migration of the Serena Central community is currently underway. Be sure to read THIS MESSAGE to get your new login set up to access your account.
mudit_gupta Valued Contributor.
Valued Contributor.
165 views

Scripts not running properly via Crontabs

Jump to solution
 

I have implemented eDirectory and other scripts in my environment as iam user as eDirectory has been installed via iam user (non-root) as well,  so here's the issue:

>> I have implemented Backup Script for eDirectory  and one of the lines in script includes taking a full backup every day

dsbk backup -f /opt/iam/scripts/eDir_bkp/TodayBackup/FullBackup.bak -l /opt/iam/scripts/eDir_bkp/TodayBackup/Backup.log -e *** -t -b

 

Now if I run the script manually, the full backup will be generated in the mentioned path but if I run the script via cronjob, FullBackup command won't run.

I noticed that one of the error I am getting is:

ndstrace: error while loading shared libraries: libnpkit.so: cannot open shared object file: No such file or directory

>> The same is happening for another script as well in which the command includes ldapsearch and ldapmodify, and are not running if I run the script via cronjob but works perfectly fine if I run it manually.

PS: I have implemented crontab as iam user.

 

Can someone please suggest me on this.

Labels (1)
0 Likes
1 Solution

Accepted Solutions
Knowledge Partner
Knowledge Partner

Re: Scripts not running properly via Crontabs

Jump to solution

Please review the example

* * * * * iam bash -l -c '/home/iam/script.sh 2> /home/iam/error.log'

Note the actual command is

bash -l -c

with the parameter

'/home/iam/script.sh 2> /home/iam/error.log'

The single quotation marks are mandatory. I don't have an RHEL box to test with, but as it works on SLES i'm pretty confident it'll work there either.

 

0 Likes
6 Replies
Knowledge Partner
Knowledge Partner

Re: Scripts not running properly via Crontabs

Jump to solution

Any improvement if you try something like

 

* * * * * iam bash -l -c '/home/iam/script.sh 2> /home/iam/error.log'

Please edit the time definition as you'll definitely don't want to run this each and every minute...

 

0 Likes
mudit_gupta Valued Contributor.
Valued Contributor.

Re: Scripts not running properly via Crontabs

Jump to solution

Thank you for your suggestion. I have tried the suggested changes in my crontab but noticed that the script was not running at all after the changes.

And No error logs generated as well.

 

 

Can you kindly suggest any alternate solution for the same.

0 Likes
Knowledge Partner
Knowledge Partner

Re: Scripts not running properly via Crontabs

Jump to solution

Where did you place the statement? /etc/crontab or in a file of it's own in /etc/cron.d?

Can you paste the complete statement you use?

Which OS are you running?

 

0 Likes
mudit_gupta Valued Contributor.
Valued Contributor.

Re: Scripts not running properly via Crontabs

Jump to solution

>>Where did you place the statement? /etc/crontab or in a file of it's own in /etc/cron.d?

 I am putting the statement at:

/var/spool/cron/iam (when I go to cron path and do view iam,  I can see all my scripts that run as iam user)

>>Can you paste the complete statement you use?

#ED Backup
0 3 * * * /opt/iam/scripts/ED-BackupScript/eDir_Backup.sh >> /opt/iam/scripts/cronlog/cronjob.log 2>&1

>> Which OS are you running?

NAME="Red Hat Enterprise Linux Server"
VERSION="7.4 (Maipo)"

 

0 Likes
Knowledge Partner
Knowledge Partner

Re: Scripts not running properly via Crontabs

Jump to solution

Please review the example

* * * * * iam bash -l -c '/home/iam/script.sh 2> /home/iam/error.log'

Note the actual command is

bash -l -c

with the parameter

'/home/iam/script.sh 2> /home/iam/error.log'

The single quotation marks are mandatory. I don't have an RHEL box to test with, but as it works on SLES i'm pretty confident it'll work there either.

 

0 Likes
mudit_gupta Valued Contributor.
Valued Contributor.

Re: Scripts not running properly via Crontabs

Jump to solution

Thank you so much, the solution worked.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.