I try to get a bash script running that should output the java process information to a file. Unfortunately when I add it to the crontab -e the script is not executed.

As user root the script is located in /root/bin

DATE=`date +%Y-%m-%d" "%H:%M`
PROCESSINFO=`ps aux | grep java | grep -v grep`

echo "$DATE $PROCESSINFO" >> java.log

This is the crontab -e configuration

* * * * * /root/jobs/log-crush-ftp-process.sh
* * * * * printf "test\n"

The printf "test\n" is just a test, but since the output will only go in the mail there is no result on the screen. What am I missing?

Also I have another question about Java processes. Since everything is running in a runtime enviroment, is there a command where I can get more detailed information about the processes inside the JVM?


I deleted the last line printf... and now I get mails for the script. But still no output in the java.log.


This was a really bad issue by myself. If I did mail and looked the first mail with 1 then I saw the message

/bin/sh: /root/jobs/log-crush-ftp-process.sh: No such file or directory

I thought the whole time the error means the first column /bin/sh, but the real issue was that I renamed the jobs folder to bin. After changing the cronjob to

*/1 * * * * /root/bin/log-crush-ftp-process.sh

(*/1 for every minute) the script is now executed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.