LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Suppressing password in cron log file while sending mails (https://www.linuxquestions.org/questions/linux-newbie-8/suppressing-password-in-cron-log-file-while-sending-mails-4175543012/)

forpostadds 05-19-2015 08:00 AM

Suppressing password in cron log file while sending mails
 
Hi Team,

I have setup few jobs with separate log files and separate EMail ID's for each job in my cron.
If something fails in these jobs, cron is delivering a mail to the mail ID that I have configured in cron as MAILTO= ( can be seen in crontab -l).

In this course, few passwords are also being returned as output from failed jobs which are being emailed to MAILTO ID.

I want to suppress the password while sending the cron output to the MAIL ID's.
Can anyone please guide me in this?

Note: I am not root user so I don't have access to /etc/syslog.conf.

JeremyBoden 05-20-2015 07:19 PM

Do these cron jobs have hard-coded passwords in them?

forpostadds 05-30-2015 12:28 PM

Hi Jeremy,

Thanks for checking this.

Consider my crontab is as below:
crontab -l:

MAILTO=abx@gmail.com

***** /path/job1.sh > /log_PATH/job1.log
***** /path/job2.sh > /log_PATH/job2.log
***** /path/job3.sh > /log_PATH/job3.log

Now, if job1.sh (quits)returns from its script, it will return something like..
--username abc --password xyz...

Now in mail sent to abx@gmail.com we can see as :
--username abc --password xyz...


Hence, I want to suppress the password while sending the content.
Let me know if you need any further information.

rigor 05-30-2015 08:40 PM

Hi forpostadds.

Cron will tend to output whatever output is produced when a job is run by cron. Although that might be E-Mailed, logged, or processed otherwise depending upon how cron is configured, if your job produces a password as output, then the password will tend to be included in the output from cron.

So the issue is usually more about special treatment of passwords by the job itself rather some special treatment of passwords by cron.

If job1.sh (quits)returns from its script when it is not being run by cron and produces output that includes a password, then that password will be included in the output from cron.

So naturally you need to modify your shell scripts so that they don't output passwords.

If you are having trouble doing that, then we might be able to help you, if you are using standard Linux commands and if you actually tell us which specific commands you are running.

-----

Until recently I never suspected that the Internet can be accessed from Barsoom.


All times are GMT -5. The time now is 02:50 AM.