LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-24-2011, 11:03 AM   #1
ETCKerry
Member
 
Registered: Sep 2008
Posts: 37

Rep: Reputation: 15
Problem with cron and mailx


Hello,

I'm trying to schedule the sending of an e-mail using cron with mailx (or nail). When I execute the script manually, everything works properly, but when I have cron call it, the output from mailx includes "Error initializing NSS: Security library: bad database."

I believe there is some kind of user/permissions issue, but I can't figure it out.

First, the crontab entry:
Code:
40 11 * * * MyNonRootUser /full/path/to/myscript.sh
And the command issued within myscript.sh:
Code:
echo "message body" | nail -v -s "Subject" -S smtp-use-starttls -S s        mtp=smtp://smtp.gmail.com:587 -S smtp-auth=login -S smtp-auth-user=myemail@gmail.com -S smtp-auth-password=mypassword -S from="myemail@gmail.com" -S nss-config-dir=/home/MyNonRootUser/.mozilla/firefox/xxxxxx.default -S ssl-verify=ignore myemail@gmail.com 2>&1
And the verbose output from mailx:
Code:
Resolving host smtp.gmail.com . . . done.
Connecting to 74.125.113.109:587 . . . connected.
220 mx.google.com ESMTP
>>> EHLO
250-mx.google.com at your service,
250-SIZE 35882577
250-8BITMIME
250-STARTTLS
250 ENHANCEDSTATUSCODES
>>> STARTTLS
220 2.0.0 Ready to start TLS
Error initializing NSS: Security library: bad database.
. . . message not sent.
I've also got it working using
Code:
su MyNonRootUser -c myscript.sh
but this isn't appropriate for cron, as su asks for a password.

Any ideas?

Thanks!

-Kerry
 
Old 07-24-2011, 07:25 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
The first cron issue may well be that the cron env is insufficient. This is quite normal; for security reasons it's set minimal.

For the su issue, try forcing the login so you get the target user's env

Code:
su - MyNonRootUser -c myscript.sh

Last edited by chrism01; 07-24-2011 at 07:37 PM.
 
Old 07-24-2011, 07:41 PM   #3
ETCKerry
Member
 
Registered: Sep 2008
Posts: 37

Original Poster
Rep: Reputation: 15
Ahhh - I figured it out.

I was editing /etc/crontab, but when I used crontab -e to edit the table for my user, everything worked OK.

Sorry!

-Kerry
 
  


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
mailx problem jobleep Slackware 7 11-02-2008 08:29 AM
mailx problem jobleep Slackware 1 10-30-2008 12:15 PM
mailx persistent problem rven Linux - Server 1 06-24-2008 06:48 PM
mailx problem aral SUSE / openSUSE 5 06-01-2008 01:41 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:48 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