I have a script(main.sh) which calls another script(Get_Files.sh) and gets a value in a variable like the below:
File_to_Refresh="$(sh /Aug/work/Get_Files.sh /Aug/Work/Universal_File.txt)"
Now I have to schedule the script main.sh for 3 different files i.e. the Universal_File.txt with 3 different values and on 3 different days.
So, to make the script generic, I want to pass the Universal file to Get_Files.sh from the Cron Entry only.
How Can i achieve the same?
Below is working if I run the script manually like sh /Aug/Work/main.sh /Aug/Work/Universal_File.txt but it's not working when i run it through cron.
File_to_Refresh="$(sh /Aug/work/Get_Files.sh "$1")"
Cron :
45 08 * * * sh /Aug/Work/main.sh /Aug/Work/Universal_File.txt
$1
is first argument. If cronjobs are... main.sh file1
,... main.sh file2
etc, to reference that in main.sh then$1
would befile1
when executed from cron1,file2
from second cronjob. possibly relevant post – Smock Sep 05 '19 at 09:58