[solution] Cronjob does not respect your bashrc or other library profile settings

By.

min read

My profile

Share this:

If you need a cronjob and use the exact code and user as CLI .. you may find that libraries cannot be found.

It turns out that even when using the same user on which CLI calls work, the ld_library_path is NOT read or applied.

So when using a bash shell script, make sure you have your environment paths in order before actually firing your line(s) with code.

In my case:

cron bash call to this file:

[code:1:2a24a9b68f]#!/bin/bash

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# User specific aliases and functions
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/home/dev/all_libraries:/opt/MATLAB/MATLAB_Compiler_Runtime/v714 ;
export LD_LIBRARY_PATH

# fire all code here[/code:1:2a24a9b68f]

Share this:

Leave a Reply

Your email address will not be published. Required fields are marked *