I am trying to use ant in a crontab task but it fails constantly on the <cvs> commands. The error reported from crontab is: 'cvs: not found' and the error logged by ant is: 'java.io.IOException: cvs: not found' CVS is available on the path as I set the PATH=/usr/local/bin:$PATH prior to calling the ant command in the script that is used by crontab. I checked to see if cvs can be found in crontab when it is not is an ant script and it was called without any problems. From my understanding of the cvs task, all it requires is for cvs to be on the PATH, but this does not seem to be the case. Is there anyway of specifying the location of cvs?
In my experience, when commands are executed from cron, their environment is not set. You need to execute ". ~/.profile" before running any other commands.
> Is there anyway of specifying the location of cvs? You can always use <exec executable="/path/to/cvs"> and see if it makes a difference. You could also echo the PATH before executing <cvs>. Try also <available> to confirm it's really in the path. Then some script other than Ant's own shell script could change the environment. --DD
(In reply to comment #1) > In my experience, when commands are executed from cron, their environment is not set. > You need to execute ". ~/.profile" before running any other commands. Thanks for the response. I tried calling the .profile that I normally use but crontab complained because of the 'export' command on each of the variables so I found some information on the Internet (http://www.aplawrence.com/Unixart/cron.html) that said you don't need to use export so I created a script that set all the variables required and then called the ant script but still no joy. To check if the cvs bin directory was added I echoed the PATH to a file and found it was there and also tried calling cvs directly in the script and the command was found. It only seemed to have problems in the ant script. Thanks, Stefan
> I found some information on the Internet > (http://www.aplawrence.com/Unixart/cron.html) that said you don't need to use > export so I created a script that set all the variables required and then > called the ant script but still no joy. I think this is something else. Your script is executed with some interpreter and that interpreter does require "export". In any case, add plain "set" command into your cron job script to see what environment is set and what is missing (look for PATH, HOME, TMP, etc. environment variables). You may also need to change the current directory before executing any commands.
ping, is this still an issue?
Stefan, is this still a problem? I'm going to close it as worksforme, because its a cron setup problem, not ant.