Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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 ajoutée par Mostafa Mohamed Abdelrahman Mohamed , Senior Virtualization and Application Management Executive , Qatar National Bank - ALAHLI
Date de publication: 2015/04/22
Utilisateur supprimé
par Utilisateur supprimé

  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
par 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
par 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
par Roshan Firozkhan , IT System Administrator , Emirates Driving Institute

 

#crontab -e 

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

More Questions Like This