Parameters in crontab

 
Thread Tools Search this Thread
Top Forums UNIX for Beginners Questions & Answers Parameters in crontab
# 1  
Old 01-09-2017
Parameters in crontab

I need to write a shell script which send an alert if a particular script scheduled in cron is not triggered.

My concern is that particular script which is scheduled in crontab, runs at night but it requires a file from upstream system as a feed prior to execution. it waits for that file upto 4 hours from the scheduled time and it triggers as soon the file come from upstream system. in simple words, script will wait for the file from upstream till 4 hours from the scheduled time in crontab. How I can proceed with the monitoring script which can alert me in case this script don't get triggered?

Appereciate the response from any member on this forum.

Last edited by Ankit Srivastav; 01-09-2017 at 07:00 AM..
# 2  
Old 01-09-2017
Welcome Ankit Srivastav,

How is your script waiting for up to 4 hours? Could that not have a section where the time has exceeded the limit and it fires an alert?

Alternatives might be to have your main script write a message in a log file that you alerting script can read 4 hours (and a little bit) after the main script is called in. This could be via a separate cron job or by you main script sending this in at the beginning:-
Code:
(sleep 14410  # 4 hours (and 10 seconds)
/path/to/checker.script ) &

A few more questions:-
  • What have you tried so far?
  • What would you expect you main script to do if the file has not arrived?
  • If it is a large file, how do you check that the file is complete before you start processing it?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)
Most importantly, What have you tried so far?

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.



Kind regards,
Robin
# 3  
Old 01-09-2017
Some of the things

Quote:
shell script which send an alert if a particular script scheduled in cron is not triggered.
  1. Did you check with cron logs?
    $ tail /var/log/cron
  2. What is the exit code of your script ? (pseudo code below)
    0 0 * * * (./script_waits_4hrs_then_fails.sh ) && ( mail -s "Success" ) || ( mail -s "Failed")
  3. May be modify the script to be more proactive and report to you before it decide to fail. ( Provide the script, we can suggest on certain "pro-activeness" for script. )
  4. If your don't want to modify the script then write another script to monitor the file and logs after the file downloaded is processed.
    Around the lines
    1. Check every X mins interval if file is available at "upstream" ? in four hours of time.
    2. If file appears then check if "script" writes any logs etc. If there is some activity, we have file and it started processed.
    3. Another way is to check for any process that the script is suppose to call example database call or other connections. Any binaries etc ..


Hope you get your answer and share your solution.

---------- Post updated at 08:27 AM ---------- Previous update was at 08:21 AM ----------

Also if your script does give out good output and if there are not many in cron jobs. Many be adding MAIL to will get you output of script. Make sure Mail server setup is good.
Code:
MAILTO=me@domain.com


Last edited by rbatte1; 01-09-2017 at 09:35 AM.. Reason: Converted textual numbered lists into formatted numbered lists
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Input parameters

friends and I can validate whether to run the shell has input parameters m event date, I occasionally happen something like this does not work if $ 1 is null then echo has entered input parameters else echo "parameter ok" fi (2 Replies)
Discussion started by: tricampeon81
2 Replies

2. UNIX for Dummies Questions & Answers

Crontab not processing parameters sent to script.

Hello All, I'm running Debian on a ThinkPad X1/2G and all seems to be running well. However, it's got a SSD that needs the trim command run at regular intervals. I'm implementing this using cron and a shell script, as recommended. The cron job entries are as follow: 0 * * * *... (8 Replies)
Discussion started by: ASGR
8 Replies

3. Shell Programming and Scripting

Passing Parameters to Crontab

Hello Experts, I have a requirement to pass some parameters to Linux cron tab. For ex: My default cron entry looks like this as below: ------------------------------- 55 10 * * --... (7 Replies)
Discussion started by: MaheshChaudhari
7 Replies

4. Shell Programming and Scripting

Getting parameters

Hi, I have 2 scripts one master.sh and child.sh. The master runs on a separate server and pushes the child script to the desginated server and runs it.The child script configures the designated server for our day to day use and it has lot of interactive questions which help the... (4 Replies)
Discussion started by: a12ka4
4 Replies

5. AIX

tuning network parameters : parameters not persist after reboot

Hello, On Aix 5.2, we changed the parameters tcp_keepinit, tcp_keepintvl and tcp_keepidle with the no command. tunrestore -R is present in inittab in the directory /etc/tunables we can clearly see the inclusion of parameters during reboot, including the file lastboot.log ... (0 Replies)
Discussion started by: dantares
0 Replies

6. Shell Programming and Scripting

More than nine parameters

Hi, please tell me the systax for passing 11 variables(including 4compulsory variables) in shell program. ORA_USERPASS=`echo $1` USERID=`echo $2` USERNAME=`echo $3` REQUESTID=`echo $4` P5=`echo $5` P6=`echo $6` P7=`echo $7` P8=`echo $8` P9=`echo $9` shift P10=`echo $9` shift... (3 Replies)
Discussion started by: anitha126
3 Replies

7. Shell Programming and Scripting

parameters

i'm supposed to come up with a script that -accepts a directory as an optional command line parameter -display an error message and terminates if more than one parameter is provided -use the current directory if no parameter is provided -displays an error message and terminates if the provided... (4 Replies)
Discussion started by: jaay
4 Replies

8. Shell Programming and Scripting

Parameters in loop

Hi, I am trying to write a script which will read inputs form user and process those files, I have issue reading the input parameters in a loop. Following is the script... I run the script as ./Script.sh 3 table1 table 2 table3 NumberOfTables=$1 let TableCount=1 while do ... (3 Replies)
Discussion started by: mgirinath
3 Replies

9. Shell Programming and Scripting

parameters

I have a script that needs to check if the given parameters are a combination of 0123456789 and not a word or another irelevant character.please help (6 Replies)
Discussion started by: aekaramg20
6 Replies

10. Shell Programming and Scripting

Need Parameters Help.

I can test for one parameter but anything more then that and I get an Error. I forgot I run this batch in a shell #!/bin/sh ------------------------------------------------------------------------- Write a batch program that accepts a keyword as a parameter and finds all the files... (3 Replies)
Discussion started by: james2006
3 Replies
Login or Register to Ask a Question