1

Am writing a simple java script to send email it works perfectly however it does work in the crontab. the command sh sendmail.sh works

Here is my crontab command from crontab -e

*/5 * * * * sh  user /home/user/classes/sendmail.sh

I expect this to work and send mail every 5 minutes but it doesn't work

However the command sh sendmail.sh works

I need help on the crontab

5
  • Your cron expression is correct, can you give us additional details? Commented Aug 13, 2014 at 8:48
  • can you add the content of sendmail.sh Commented Aug 13, 2014 at 8:48
  • java -classpath .:mail.jar:imap.jar:dsn.jar:smtp.jar:gimap.jar:mailapi.jar:pop3.jar email.Email nothing happens from the crontab job and no email is sent Commented Aug 13, 2014 at 8:54
  • Note- By default crontab sends a mail to user account executing the cronjob, why dont you make use of it? Commented Aug 13, 2014 at 8:55
  • i got this message from cat /var/spool/mail/user /bin/sh: user: command not found Commented Aug 13, 2014 at 9:01

2 Answers 2

1

thanks guys but I found the solution

this code works

*/5 * * * * (cd /home/user/classes; sh mail.sh)
Sign up to request clarification or add additional context in comments.

Comments

0

Your correct lines is the following

*/5 * * * * user /home/user/classes/sendmail.sh (without "sh" word)

You have to be aware that user "user" has permission to execute the script "sendmail.sh"

You can see that executing ls -la sendmail.sh and reading who is the owner and the permissions.

1 Comment

*/5 * * * * (cd /home/user/classes; sh mail.sh) thanks this worked

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.