Mike Leone on 30 Apr 2010 08:15:53 -0700

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Script doesn't seem to run in cron...

On 4/30/2010 10:19 AM, LeRoy had this to say:
> Hash: SHA1
> On 04/30/2010 09:29 AM, Mike Leone wrote:
>> I have a script I want to execute at a scheduled time. I can run the
>> script from the command line with no problems - it executes correctly.
>> But doesn't seem to run from cron (at least, I get no output files in  a
>> certain directory, as I do when I run it from a command line).
>> And I can't seem top find a cron log anywhere. I see in syslog that it
>> is executing (I think), but I don't know why it's not working.
>> $ sudo crontab -l
>> # m h  dom mon dow   command
>>    30 9  30   4   * /Scripts/Get-Invoices.sh
> Hi Mike,
> I think that your problem could be that you need to put the complete
> path of the executables in the script.  For instance, when you call a
> simple command like cp or anything else, you need to specify the path to
> cp by calling /bin/cp
> Also you could try to set the PATH at the start of the script.  I have
> noticed that cron does not use the path of the user.

Good idea. Still not working, tho. :-(

$ cat /PHA-Scripts/Get-Invoices.sh
#!/bin/bash -
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
/usr/bin/ssh FileCollector@address '/PHA-Scripts/snag-files.sh' && 
/usr/bin/rsync -rvz --timeout=30 --delete-excluded 
FileCollector@address:/home/FileCollector/snagged-files/  /VendorInvoices/
/usr/bin/unzip -j /VendorInvoices/*.zip -d /VendorInvoices
/bin/cp /VendorInvoices/*.zip /VendorInvoicesArchive/
/bin/rm /VendorInvoices/*.zip
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug