bash - cron job - ack: command not found -


I have a bass script that has been written to identify if a certain string exists in the file and then Output "NoString.txt" has the file name "hasString.txt". I am using ack -i 'mystring' 'searchDir' which I am looking for.

The strange thing is that when I manually call the script through the terminal works perfectly, but when the crystal script calls I get the following error message output:

~ / sourceDir / script.sh: line 30: ack: command not found .

Cron is called manually when called by, but why is not AC able to search the command?


Edit: Adding relevant code and cron file

Lookout script - Determines that there is no file to process.

  If [[$ (ls-A $ {PWD} / * .zip)]]; Then [$ different - 1 point]; Do du -h 1 & gt; $ Comparison 1 ls -laR & gt; & Gt; $ Comparison 1 Sleep 25s du -h 1 & gt; $ Comparison 2 ls -laR & gt; & Gt; $ Compare2 if CFP $ compare $ 1; Then mkdir -p $ LOGAREA mkdir -p $ workarea / zip opening touch $ touch touch $ ERRORLOG sleep 2s source ~ / desktop / script / readfolderfiles.sh $ drop mv * epub $ workarea rm $ compare1 rm $ compare2 bash ~ / desktop /Scripts/Page_Label/script/searchString.sh Varies = 0 other Echo Fin 1 & gt; $ LOG 2 & gt; Identify $ ERRORLOG left rm ~ / desktop / page_labels.running rm $ drop / page_labels.running fi  

and generate report script - output mentioned at the top

< * .zip for pre> files; Zip -d / zip open / $ {files% #move and files mv $ workarea / $ files $ workarea / zip / opening / $ {files% .epub} zip sleep 2s zip unzip unzip / unzip / * .. Epib} MV zip / unzip / *. Zip Zip Sleep * 2s * $ for CADA / Zip / Open DIR; Find files for Do # searchstring if ack --ignore-case 'searchstring' $ dir; Then $ dir> & Gt; $ Drop / has_searchString.txt echo RM-R $ dir sleep 5s afo $ dir & gt; & Gt; $ Drop / no_searchString.txt echo rm -r $ dir sleep 5s fi cd $ workarea

cron doc

  #! / Bin / bash path = / sbin: / bin: / usr / sbin: / usr / bin: / usr / local / bin #### Backup files * * * * 1,2,3,4,5 Bash ~ / Desktop / script / searchScript .sh & amp; & Gt; / Dev / null;  

You have to set the Path Environment variable in your cron job. Then add this to the top of the Cron file:

  # / bin / bash path = / sbin: / bin: / usr / sbin: / usr / bin: / usr / local / bin  

Note: also #! Add bin / bash, so that you have to add shell enviroment variable too.


Comments