Solved

How to set  script to be auto-launched everyday?

Posted on 2015-01-05
5
167 Views
Last Modified: 2015-01-11
There is some script in a unix machine i need to lauch manually everyday at certain time, it returns a string value, i would like to set up some script to check this automatically everyday and send an email to my address with the result, i know alread how to send the email, but i don't know how to set the script to lauch this other script, get the result and send it to me.
0
Comment
Question by:celtician
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 40532433
see `man 5 crontab`
0
 
LVL 48

Accepted Solution

by:
Tintin earned 250 total points
ID: 40532481
crontab -e

which will put you in an editor, then you add something like

0 23 * * * /path/to/your/script

Where, the first two fields are min and hour, so in this example, the script would run everyday at 11pm
0
 
LVL 40

Assisted Solution

by:omarfarid
omarfarid earned 150 total points
ID: 40533008
If you want to capture script output and based on it decide to send email then you may do the following in the calling script:

1- set env variables e.g. PATH, etc.
2- use full path names to folders and files

The calling script that you use in crontab job, can be similar to:

result=`/path/to/myscript`
case $result in
res1|res2)
                 sendmail -s "email for result $result" username@domain.com
                 ;;
res3|res4)
                 sendmail -s "email for dif result $result" username@domain.com
                 ;;
*)
                sendmail -s "no matching result" username@domain.com
                ;;
esac
0
 

Author Comment

by:celtician
ID: 40533956
Tintin and whats the meaning of the three asterisks after 0 and 23???
0
 
LVL 62

Assisted Solution

by:gheist
gheist earned 100 total points
ID: 40534081
recent vixie-cron says this:

              field          allowed values
              -----          --------------
              minute         0-59
              hour           0-23
              day of month   1-31
              month          1-12 (or names, see below)
              day of week    0-7 (0 or 7 is Sunday, or use names)
A field may contain an asterisk (*), which always stands for "first-last"


Next field is username in /etc/crontab only
then starts command (i.e no username for other crontabs)

always use crontab command line to edit users' crontab.
0

Featured Post

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tech tip describes how to install the Solaris Operating System from a tape backup that was created using the Solaris flash archive utility. I have used this procedure on the Solaris 8 and 9 OS, and it shoudl also work well on the Solaris 10 rel…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question