Cron entry to pass the value to script


 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Cron entry to pass the value to script
# 1  
Old 09-09-2019
Cron entry to pass the value to script

0


I have a script(main.sh) which calls another script(Get_Files.sh) and gets a value in a variable like the below:

Code:
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.

Code:
File_to_Refresh="$(sh /Aug/work/Get_Files.sh "$1")"

Cron :

Code:
45 08 * * * sh /Aug/Work/main.sh /Aug/Work/Universal_File.txt

# 2  
Old 09-09-2019
Hi,

I suspect that your cron job is working correctly, in that it will spawn a shell and close. You should be able to see out put in your local mail "Q".

Try running the shell script on it's own as follows;

Code:
45 08 * * * /Aug/Work/main.sh /Aug/Work/Universal_File.txt

But I suspect that you may have to take your input file and call from inside your shell script.

Regards

Gull04
These 2 Users Gave Thanks to gull04 For This Post:
# 3  
Old 09-10-2019
Yes, it works. The argument /Aug/Work/Universal_File.txt lands in $1.
The prefixed sh allows the /Aug/Work/main.sh to not be executable.
This User Gave Thanks to MadeInGermany For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Cron entry

Hi I have a system running solaris 11, in which I am able to execute a script from the command line, but once I put i the crontab does run, but do not give results. The entry is: 15 11 * * * /var/oswbb/./startOSWbb.sh >> myjob.log 2>&1 30 11 * * * /var/oswbb/./stopOSWbb.sh I have check... (2 Replies)
Discussion started by: fretagi
2 Replies

2. AIX

Commands to call script work from command line but not from Cron entry

My first post evidently did not materialize so I posted it again: Runnning a cron job every 5 mins to send data files to a state facility. My original cron entry at worked fine: 01,06,11,16,21,26,31,36,41,46,51,56 * * * * /home/sftpuser/stateinoc-from-appname.ksh Somewhere I have a... (1 Reply)
Discussion started by: Skyybugg
1 Replies

3. Shell Programming and Scripting

Commenting out a cron entry through a shell script

In my cron thare is a line like 24 11 * * * /usr/batch/bin/abc.sh > /usr/batch/log/abc.log 2>&1 along with other entries. I want to comment out this line through a shell script. My local variable 'line'ontains the full entry (i.e. 24 11 * * * /usr/batch/bin/abc.sh > /usr/batch/log/abc.log... (4 Replies)
Discussion started by: Soham
4 Replies

4. Solaris

cron entry

Hi, I have to add two cron entry now. Please correct me if anything wrong Below script should run at every one and half hour. 30 01 * * * /export/home/gxadm/scripts/collect_mq_info.pl $HOME/GCSS/logs > /dev/null 2>&1 Below script should run at every 2 hours 0 02 * * *... (9 Replies)
Discussion started by: Mani_apr08
9 Replies

5. Shell Programming and Scripting

get system date, format it, pass it as a parameter to a perl script - all in cron job

I am trying to get the string containing date - in a specfic format actually, although I think that part is inconsequencial - 1110226^1110226^1110226^1110226^1110226 - through echo or printf or in some other way - created within a cront job and passed as a parameter to a perl script. Now, I know... (3 Replies)
Discussion started by: v8625
3 Replies

6. UNIX for Advanced & Expert Users

cron entry

Hi, I need some clarification on cron entries. I have a cron job like.. 15 01 19 02 6 exec /usr/bin/test.ksh and I have another cron entry added, which is 15 01 20 02 6 exec /usr/bin/test.ksh So, I am thinking the second cron entry shouldn't have run because 02/20 is Sunday, but... (1 Reply)
Discussion started by: everurs789
1 Replies

7. Solaris

User entry in both cron.allow and cron.deny

Hello All, Anybody please help me to know ,what happens when a user having entry in both cron.allow and cron.deny files.Wheather the user will be able to access the crontab??? Thanks in advance Vaisakh (5 Replies)
Discussion started by: ksvaisakh
5 Replies

8. Shell Programming and Scripting

Cron Entry

Hi folks, I have got the following cron entry ... 08 30 * * * /mp1/scripts/test.sh > /mp1/scripts/test_logs.txt 2>&1 The problem is that instead of generating a new test_logs.txt file every time it keeps on appending the outputs to the test_logs.txt file. What is it that I am doing wrong... (2 Replies)
Discussion started by: King Nothing
2 Replies

9. UNIX for Dummies Questions & Answers

cron entry

Hi, Where can we find Cron job logs?i have a cron job which is not executing at all, 00 12 * * * /xx/yy/job > /pp/qq/log if i execute the job alone,it is executing fine. >/xx/yy/job > /pp/qq/log (is executing fine) but its not executing when it triggered from cron.is there any place cron... (7 Replies)
Discussion started by: rujus
7 Replies

10. AIX

Cron entry

Hi All, I want to run a cron job to run on the first saturday of each month at 1:30am. Would the following entry suffice this condition 30 1 6 * 6 wall %Will this work% Appreciate your time. (1 Reply)
Discussion started by: rramanuj
1 Replies
Login or Register to Ask a Question