This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: help cron cygwin

Christian Lanconelli (servizio) wrote:

CRON can run commands wrote in fortran containing the call system()
this is my program : trasf_DOS.f
It write a DOS batch file that is immediately run by the 'call system
("copio.bat")' statement-
It WORK WELL in the bash shell (cygwin because I use the DOS commands xcopy)
but can't run as a cron scheduled job.
Both trasf_DOS.exe, and copio.bat, are in the $PATH.

Administrator@ragas /cygdrive/c/cvi/ICARO/dati
$ ./trasf_DOS.exe  <Carriage Return>

sab 07/01/2006
 Prima della trasformazione: 7 1 2006
 Dopo la trasformazione: 6 1 6
 === Copio i file lanciando il batch appena creato ===
c:\cvi\ICARO\dati>xcopy c:\cvi\ICARO\dati\??060106.*  \\pc27\CO2_O3\ /D /F
C:\cvi\ICARO\dati\DD060106.GAS -> \\pc27\CO2_O3\DD060106.GAS
C:\cvi\ICARO\dati\DD060106.MET -> \\pc27\CO2_O3\DD060106.MET
C:\cvi\ICARO\dati\DD060106.RAD -> \\pc27\CO2_O3\DD060106.RAD
C:\cvi\ICARO\dati\MN060106.DEU -> \\pc27\CO2_O3\MN060106.DEU
C:\cvi\ICARO\dati\MN060106.GAS -> \\pc27\CO2_O3\MN060106.GAS
C:\cvi\ICARO\dati\MN060106.MET -> \\pc27\CO2_O3\MN060106.MET
C:\cvi\ICARO\dati\MN060106.RAD -> \\pc27\CO2_O3\MN060106.RAD
7 File copiati

(end of trasf_DOS.exe)

Administrator@ragas /cygdrive/c/cvi/ICARO/dati
$ echo $PATH

3) Here are the crontab -l output:
Administrator@ragas /cygdrive/c/cvi/ICARO/dati
$ crontab -l
40 * * * * trasf_DOS.exe;echo "tab eseguito alle

The file "cronlog" is regularly updated. But trasf_DOS appears not work!

Can you help me? What's my error?

It's a common cron misconception that occurs across all platforms on which it runs. The fact that a script runs when logged in but not in cron suggests that it is a path issue. Don't assume the path is right. Don't assume that things cron runs will have exactly the same environment you have on the command line. Write defensively scripts/apps that cron will run. In this case, providing the fully qualified path to your executable and copio.bat when they are invoked should help. Keep in mind as well that Cygwin compiled programs are going to invoke Cygwin's system(), not Windows, and that .bat files aren't going to be interpreted properly by any Cygwin shell. So you'll probably want to invoke a fully qualified "" or "cmd.exe" as part of your system() call, depending on your target platform.

-- Larry Hall RFK Partners, Inc. (508) 893-9779 - RFK Office 838 Washington Street (508) 893-9889 - FAX Holliston, MA 01746

-- Unsubscribe info: Problem reports: Documentation: FAQ:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]