Solved

How to set  script to be auto-launched everyday?

Posted on 2015-01-05
5
160 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
5 Comments
 
LVL 84

Expert Comment

by:ozo
Comment Utility
see `man 5 crontab`
0
 
LVL 48

Accepted Solution

by:
Tintin earned 250 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Tintin and whats the meaning of the three asterisks after 0 and 23???
0
 
LVL 61

Assisted Solution

by:gheist
gheist earned 100 total points
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now