Solved

crontab unix questions

Posted on 2011-09-13
4
532 Views
Last Modified: 2012-05-12
experts,

i'm a complete novice at unix and am working my way through scheduling a scheduled task using crontab. i've created a .sh file that calls a .sql file that inserts one record into a database. if i run the .sh file using sh myfile.sh it works as expected. I added an entry to my crontab file to run the file but keep getting a permission denied error. looking at my crontab file I can see other entries there already, so I know the user i have has permissions.

what could i be doing wrong?

thanks in advance for the help.
0
Comment
Question by:telliot79
  • 3
4 Comments
 

Author Comment

by:telliot79
ID: 36532548
the error message i'm getting is "/home/sybase/myfile.sh: Exdecute permission denied."

as stated, i see other jobs firing other tasks from that folder that work fine.
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 350 total points
ID: 36532565
Hi,

Please use full paths to all executables, in crontab as well as in the called script.

Next, either use sh /path/to/myfile.sh or, if you don't want to use the "sh ..." method, issue "chmod +x /path/to/myfile.sh" before running it. This makes the file "executable" and makes the "sh" prefix unnecessary.

For completeness you should add

#!/bin/sh

as the first line to your script.

Finally please be aware that cron does not run shell initialization profiles, so there is no PATH except for /usr/bin and there are no environment variables except for a few things like HOME, SHELL etc.

wmp
0
 

Author Comment

by:telliot79
ID: 36532749
genius........

I needed to make the file executable. thanks for the help - only wasted half my day playing with this.

and thanks for the thorough explanation. very helpful.
0
 

Author Closing Comment

by:telliot79
ID: 36532757
genius
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
The purpose of this article is to demonstrate how we can use conditional statements using Python.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now