Solved

crontab unix questions

Posted on 2011-09-13
4
541 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

895 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