Question

i was getting this error in cron job

 /usr/bin/env: node: No such file or directory

so i did this

 */10 * * * * . $HOME/.bashrc sh /path/to/cronjob.sh

in my cron job

but then it gives me this error

 /etc/cron.daily/man-db:
 /usr/bin/mandb: can't set the locale; make sure $LC_* and $LANG are correct
Was it helpful?

Solution

When you are doing this directly in the cron entry: . $HOME/.bashrc you are actually asking the user cron to set its environment and most likely it has no Locale defined.

You should set your environment in your script directly just after setting the bash directive:

    #!/bin/bash
    . $HOME/.bashrc
    echo Hello World

It would be better if you configure .bash_profile to load .profile and then load .bashrc

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top