ace ace - 6 months ago 16
Linux Question

Execution of bash file with java file from crontab

I wrote a bash file in which I am executing java file, its working properly if I am executing it but when I am trying with crontab it is not ,please help.

this is my crontab :

*/5 * * * * /home/import.sh >/dev/null 2>&1


this is my bash file:

- me=$(date +%Y-%m-%d)
mkdir -p /home/importRequirement"$foldername"
{
java -jar ImportRequirement1.jar
java -jar ImportRequirement1.jar
}

2>importRequirement"$foldername"/log$(date +%Y-%m-%d-%H-%M-%S).txt


I have deleted the url.

Answer

The environment variables for cron jobs is not the same as what users get when they are logged in. Double check the environment variables you need to run your script (ie JAVA_HOME and PATH). cron might not know with what to interpret your script, you might want to place

#!/bin/bash

on the first line of your bash script.

Comments