![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| error in running shell script in cron | sari | Shell Programming and Scripting | 3 | 04-16-2008 01:09 AM |
| Email sending through a shell script | memonks | UNIX for Dummies Questions & Answers | 3 | 11-11-2007 09:21 PM |
| Sending attachments using email through shell script | symhonian | Shell Programming and Scripting | 6 | 01-27-2006 06:41 AM |
| sending email from KSH unix script. | rosh0623 | Shell Programming and Scripting | 3 | 07-26-2005 12:36 AM |
| Cron running shell scripts. | cfoxwell | UNIX for Dummies Questions & Answers | 3 | 09-26-2001 08:35 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Running a shell script in cron...email not sending - help??
I am pretty new to Unix shell scripting, but wondered if anyone could help (in layman's terms if possible!!)
I have a shell script which ultimately sends an alert to an email address if part of a batch of programs fails. Here's the script that sends the email: Script: 6check.csh #!/bin/csh set alertperson = `cat /export/home/bdodym/alert.person` if (-f critabend.tag ) then cat callout6.msg | rmail $alertperson rm critabend.tag endif This is where $alertperson will be forename.surname@address.com designation in the alert.person script From the command line, all runs fine. However, if I run through cron, it still seems to be executing the scripts (e.g files are created that I'm asking the script to do generally), but the email is not being sent as I would hope. In the below crontab, 6start.sh has a number of scripts to run through, the last of which is 6check2.csh (as per above) crontab -l #!/bin/csh ############################################# # Minute Hour Month Day Month Weekday Command # ___________________________________________________________ # 0 01 * * * Job_1 # 51 * * * * /export/home/bdodym/6start.sh Does anyone know if there is anything additional I need to do add to either the script, or cron, to ensure the email sends? I think (from my VERY limited knowledge of this kind of thing!) that its something to do with the fact cron is running in the background rather than the terminal, as per the command line success. But, this is the final piece of the jigsaw and I just need to ensure I can get it to fit!! |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Have the output of that cronjob redirected to some file like
Code:
51 * * * * /export/home/bdodym/6start.sh >> /somelogdir/6start.sh.out 2>&1 Don't forget that cronjobs usually don't have the same environment like when a user would start the script - so you should source the .profile or .kshrc or .bashrc, whatever your environment setup files are. |
|
#3
|
|||
|
|||
|
zaxxon - thankyou for your reply. I was just reading up about "source". So if I were to source it, would I just add the source to 6check.sh (the emailing bit) or 6start.sh too (which, as mentioned just contains a list of scripts to run, as per below...)
#!/bin/sh 6jobstatus.sh 6clean.sh 6check.sh 6check2.csh Thanks, Tim |
|
#4
|
|||
|
|||
|
use vi editor to create a file using .sh extension which will have shell scripts to execute.
then execute this file using command sh filename.sh e.g. if u have created a shell file sample.sh then u will execute this file using sh sample.sh this command... go and try different kinds of shell scripts you will definitely explore more about UNIX. |
|
#5
|
|||
|
|||
|
Hi sumitbabar
I already have the .sh extensions, my problem is my emails aren't sending when run from cron. All is fine from the command line. Thanks, Tim |
|
#6
|
|||
|
|||
|
The FAQ section has an extensive posting about troubleshooting cron jobs. cron and crontab
|
|
#7
|
|||
|
|||
|
Give full permision
Try to give full permission for that file
or chmod 755 finename |
|||
| Google The UNIX and Linux Forums |