ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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
تم إضافة السؤال من قبل Mostafa Mohamed Abdelrahman Mohamed , Senior Virtualization and Application Management Executive , Qatar National Bank - ALAHLI
تاريخ النشر: 2015/04/22
مستخدم محذوف‎
من قبل مستخدم محذوف‎

  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
من قبل 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
من قبل 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
من قبل Roshan Firozkhan , IT System Administrator , Emirates Driving Institute

 

#crontab -e 

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