I need to send a personal env variable $FTP111_PASSWD defined at my personal .bashrc to crontab execution. How to set an environment variable on crontab?
My original shell script, named cron4_etc.sh, created for crontab execution was:
#!/bin/bash cd /myFolder/ ftp -n -i <<EOF open 101.111.111.111 user myUser "$FTP111_PASSWD" mget check_*.log bye EOF If I execute the script via terminal ./cron4_etc.sh it is executing fine, but if I have start it using the following crontab line
*/20 * * * * /home/myUser/cron4_etc.sh > /tmp/cron4.log 2>&1 crontab says
Password: Login incorrect.\nLogin failed.
I tried to improve my script using this suggestion, but the error persists:
#!/usr/bin/env bash # set environment source /home/myUser/.bashrc cd /tmp/pg_io/PGW ftp -n -i <<EOF open 101.111.111.111 user myUser "$FTP111_PASSWD" mget check_*.log bye EOF PS: I am using Ubuntu 18 LTS, but the question is for generic crontab.
$FTP_etc_PASSWDvariables,.bash_profile? 2. how to "run this place" at my Crontab script? ... Or the best is put in/etc/environment?