LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 05-14-2018, 08:58 PM   #1
skagnola
Member
 
Registered: May 2017
Distribution: CentOS
Posts: 41

Rep: Reputation: Disabled
Using CentOS 6.9 wget 1.14 cronjob but not pushing error exit status email


I'm trying to use a cronjob to download a file from a URL, but add a step to email if there is any exit status other than 0. wget is using a .wgetrc for the login credentials to pass to the URL auth. The .wgetrc is located in the same dir where the job is running from.

Here is the job

Code:
37 20 * * * /home/user1/dwnld > /tmp/dwnld.log 2>&1
Script
Code:
#!/bin/bash
export HOME=/home/user1
set -e
set -o pipefail
retval=0

cd /home/user1

retval=$(wget http://location.tar.gz)
if [ $? -ne 0 ] ; then
  cat /tmp/dwnld.log | mail -s "Error Report" -r "root@vmname.local" "skagnola@domain.com"
fi
I have the credentials set incorrectly to test the error out email.

This is the out log

Code:
--2018-05-14 20:37:01--  http:location.tar.gz
Resolving location.org (location.org)... [IP ADDR]
Connecting to location.org (location.org)|[IP ADDR]|:80... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Reusing existing connection to location.org:80.
HTTP request sent, awaiting response... 401 Unauthorized
Authorization failed.
Presumably the Authorization failed means EXIT STATUS 6 but its not sending the email.

When I run the mail line alone, it sends. The user running the job has write access to the output dir as well as the dir the job is running from.

If I run it with the correct credentials set, it works. I just need to set something up to notify when something blows up.

I must be doing something wrong with the way I'm presenting this to cron? Maybe perms on the script? Should it be run as a root user?
 
Old 05-15-2018, 01:45 AM   #2
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,781

Rep: Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199
cron jobs have a minimal environment.
Check your current environment for HTTP proxy setting.
Code:
env | grep -i proxy
Define the same in the cron script, for example
Code:
export http_proxy=100.101.102.103
 
Old 05-15-2018, 09:01 AM   #3
skagnola
Member
 
Registered: May 2017
Distribution: CentOS
Posts: 41

Original Poster
Rep: Reputation: Disabled
Hey, Germany! Thanks for the response!

Turns out that the environment on this VM does not have that option configured. I figured the #!/bin/bash and export HOME=/home/user1 bits would set the cron environment as the user it is being run from, based on dialog here and there. I'm wondering if that is ignored now?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Error non-zero exit status 32 BasieBop Linux - General 1 10-25-2017 03:36 AM
Error: ld returned 1 exit status przi Linux - Software 2 01-06-2016 12:53 PM
error exit status 1 LinuxSU Linux - Software 22 09-17-2015 04:12 PM
building sge-8.1.3 error - collect2: error: ld returned 1 exit status Reignfire Linux - Software 0 05-08-2013 01:45 PM
error exit status 30 debian_dummy Debian 2 09-21-2004 10:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:44 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration