I'm a java developer, and always try to learn something new.
I'm newbie to crontab. Was trying a task to write a data validation script using crontab.
Job in shell script is as follows
1. Get the info from config file.
2. Connect to DB
3. call a proc to validate the data and write invalid records to db utl file.
4. If file contains invalid records, mail the file as an attachment.
I could successfully write quarter to 4 steps.
The part 'file as an attachment' was reminding me that you are newbie to crontab.
Running the individual shell was working good ..email, attachment and validations..all good..but running script using crontab was not working for attachments
Googling around, could find few possible reasons and solutions for this....but nothing worked... :-(
Mail part was working correct but without attachments...... !!! ???? Why whyyy whyyyyyyy ..but no answer...
Finally, no option, I had to ask for help from my crontab expert friend (Pradip).
He suggested to put '. $HOME/.bash_profile' at the top of shell script where I had wrote '. $HOME/.profile'.
Trust friends, this worked at first go .... wowwww...
I asked him... how ?
The answer is ..running the individual shell script has access to PATH, but crontab might not necessarily have access to PATH.
So to have access to PATH, one should run '.profile' before crontab.
But I had already written '. $HOME/.profile'. then ?
It was not my default profile.. login to server..cd your /home and type 'ls -al'
You will see the default profile file.
'. $HOME/.profile' in my shell was 'copy-paste' from web :P
Subscribe to:
Post Comments (Atom)
SpringBoot: Features: SpringApplication
Below are a few SpringBoot features corresponding to SpringApplication StartUp Logging · To add additional logging during startup...
-
There was a requirement in which user should be able to download an excel report from application, make some amendments and upload the exce...
-
I was facing 'java.rmi.NoSuchObjectException: Bean has been deleted' for the stateful bean instance. While reading about the error, ...
-
What Is a WebLogic Server Cluster? A WebLogic Server cluster consists of multiple WebLogic Server server instances running simultaneously an...
No comments:
Post a Comment