?
Solved

crontab unix questions

Posted on 2011-09-13
4
Medium Priority
?
570 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 1400 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
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.:
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

719 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