Solved

crontab unix questions

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
FTP Script 25 91
Post Clonezilla image restore issue 6 89
user defined, environmental. local, global variables 4 26
Issue when using 'yum update' 4 23
Utilizing an array to gracefully append to a list of EmailAddresses
Fine Tune your automatic Updates for Ubuntu / Debian
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

739 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