Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

When running command in crontab scheduled job it cannot see path /usr/local/bin how can I add this path to the environment variable PATH in crontab?

when running command in crontab scheduled job it cannot see the path /usr/local/bin how can I add this path to the environment variable PATH in to be seen by crontab?

user-image
Question added by Mostafa Mohamed Abdelrahman Mohamed , Senior Virtualization and Application Management Executive , Qatar National Bank - ALAHLI
Date Posted: 2015/04/22
Deleted user
by Deleted user

  1. Specifiy path directly into cronjob fileExample -  SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
   

Mostafa Mohamed Abdelrahman Mohamed
by Mostafa Mohamed Abdelrahman Mohamed , Senior Virtualization and Application Management Executive , Qatar National Bank - ALAHLI

I don't want to set it as all time scheduled job to set PATH I want to set it in place/file where crontab call this variable.

I see that I can add this variable to my script also I can set the full path of the command which run.

as /usr/local/bin/sshpass.

I want to know which file I have to modify for crontab to read the new modified PATH env variable?

Muhammad Anzar
by Muhammad Anzar , DevOps/DevSecOps Architect , Confidential

We can use multiple options for env path into cronjob

 

  1. Specifiy path directly into cronjob fileExample -  SHELL=/bin/sh PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  2. Second, run source /etc/profile from cronjob files always

Roshan Firozkhan
by Roshan Firozkhan , IT System Administrator , Emirates Driving Institute

 

#crontab -e 

* * * * * PATH=$PATH:/usr/local/bin /path/to/your/cronjob 

More Questions Like This