Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

How to set  script to be auto-launched everyday?

Posted on 2015-01-05
5
Medium Priority
?
172 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 85

Expert Comment

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

Accepted Solution

by:
Tintin earned 1000 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 600 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 400 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.:
Suggested Courses
Course of the Month8 days, 20 hours left to enroll

877 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