How to detect if java is run from cron or through interactive shell.
I need to determine if the script is called by a user (show error message in sys.out) or cron(send error as email)
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In your your crontab job you can pass an additional command line switch like
-Dcron=trueand that you can check inside your java code to branch out your logic.