Solved

crontab unix questions

Posted on 2011-09-13
4
565 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Three Considerations for Containers

Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read our article on Experts Exchange.

Question has a verified solution.

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

Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
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.
Suggested Courses

632 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