How to read variable from file and use in cronjob | linuxtopic
Read variable from file and use in cronjob, Use variable from file and execute cron job using variable, variable in crontab.
Step 1 : Create environment file
vi /opt/env
IP=172.17.0.1
Name=TEST-USER
Place=Indore
WEB=www.linuxtopic.com
Step 2:
Create Cronjob for every min
vi /etc/cron.d/crontab
BASH_ENV=/opt/env
SHELL=/bin/bash
* * * * * root /bin/ping -w 3 $IP > /tmp/PING.log
* * * * * root echo $Name > /tmp/name.log
* * * * * root echo $Place > /tmp/place.log
* * * * * root echo $WEB > /tmp/web.log
Step 3:
check log output :
Hindi Tutorial
English Tutorial
Leave a Comment