title: script for cron.daily
body: <p>I need to have my Java program run on a linux box once a day. So I created a simple file with just one line: </p>
  
  <pre><code>java -jar /opt/location/my_jar.jar
  </code></pre>
  
  <p>and put it in etc/cron.daily, assuming it would run once a day. But it doesn't run at all. I tried both to have the .sh extension, or simply the file name with no extension. Still, no luck. </p>
  
  <p>I googled it and I'm getting quite a bit of conflicting info. Can someone please help? </p>
  
  <p>EDIT:</p>
  
  <p>I'm summarizing the place it is right now, based on the answers given by Satish and Mithrandir. </p>
  
  <p>1.I created the run_conversions script using vi, to get over the problem with the end of line character on windows. Now the script is </p>
  
  <pre><code>#!/bin/sh
  /usr/bin/java -jar /opt/location/my_jar.jar
  </code></pre>
  
  <p>2.I put it in /etc/cron.hourly. </p>
  
  <p>3.Checking the log at /var/log/cron I'm seeing the it's starting run_conversions and finishing run_conversions every hour. So far so good. </p>
  
  <p>4.But it doesn't seem like my jar file is running. I know this because when it's running properly it should update a database -- and the database is not updating. </p>
  
  <p>5.Here's the strange thing: when I'm running cron.hourly manually, but calling </p>
  
  <pre><code>run-parts /etc/cron.hourly
  </code></pre>
  
  <p>the jar file is hit propertly, and the database is updating. </p>
  
  <p>To sum it up: when running it through run-parts, it works. When leaving it to run hourly by itself, it doesn't. </p>
  
  <p>Any ideas? </p>
  
  <p>EDIT 2: </p>
  
  <p>Following advice from Satish, Mithrandir and vahid I changed my run_conversions_loc to look like this: </p>
  
  <pre><code>#!/bin/bash
  SHELL=/bin/bash
  PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bexport SHELL=/bin/bash
  /usr/bin/java -jar /opt/tf/conversions/aff_networks2.jar &gt; /opt/tf/conversions/runconversions.txt
  </code></pre>
  
  <p>I removed the script from cron.hourly and added this line to crontab: </p>
  
  <pre><code>*/10 * * * * /opt/tf/conversions/run_conversions_loc
  </code></pre>
  
  <p>The script now runs every 10 minutes, and is registered in the cron log like this: </p>
  
  <pre><code>Feb 24 09:30:01 backsome CROND[7933]: (root) CMD (/opt/tf/conversions/run_conversions_loc)
  </code></pre>
  
  <p>So far it looks good. But the database -- which it should update -- isn't updated. </p>
  
  <p>Looking deeper into it, the jar file, aff_networks2.jar is looking for an <code>ftr.properties</code> file in the local directory -- the same directory where it's at. The file exists in this directory. But it's not read properly. I know this because in the output file, runconversions.txt, the value that should be read from the properties file is null. </p>
  
  <p>Two things to complete the picture: </p>
  
  <ol>
  <li><p>Everything in the conversions directory has 777 permissions. I know it's not recommended to give such extended permissions but I wanted to make sure (at least try) it's not the issue. </p></li>
  <li><p>When I run the script from the shell by calling <code>./run_conversions_loc</code> it runs, finds the properties file, and updates the database. I am logged into the shell as root, and I also created all the relevant files as root, and installed as root the line for calling the script in crontab. </p></li>
  </ol>
  
  <p>Any ideas why isn't cron reading the properties file? </p>