0

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

#!/bin/bash
PATH=/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?

EDIT:

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

1 Answer 1

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .