[SOLVED] convert works from CLI, but doesn't work when cron'd in a .sh
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
convert works from CLI, but doesn't work when cron'd in a .sh
Hi guys. I tried to make a cron job that just runs some convert commands then moves the files somewhere for me. When i run the commands copied and pasted from my cron'd .sh they work. But they never seem to work when the cron job runs automatically.
If I do a ./scriptname.sh it works though which confuses me.
I did read some of them already. I have the full path in there for my commands. the script is executable. My guess is it's something to do with convert or the fact that convert is in usr/local/bin, where all my other programs I have cron'd are in /usr/bin, but convert has -rwxr-xr-x which is what other things I have cron'd have. Maybe I have to have usr/local/bin added somewhere i'm unaware of?
When I run the script from the command line though, it doesn't give any errors as to why it doesn't work.
99% of the time when a script works on the command line but doesn't work in cron, it's because of the environment difference (namely the PATH) - ignoring of course those cases when the cron isn't even running.
Try sticking a "> ~/convert_cron.log 2>&1" onto the end of your cron command, then check that file after it runs for clues.
If the file doesn't exist, then make sure cron is running, and make sure you have a blank line as the last line in your crontab (sometimes cron won't run the last command in the crontab if there's not a blank line after it).
Thanks, I'll give it a shot. I know the cron runs because it does everything except those convert commands. a totally uneducated guess is that it's something about the /usr/local/bin path to convert it doesn't like but i'm just guessing based off my other cron jobs using commands in /usr/bin ok.
ive only written a few basic bash scripts, but when i was learning one of the first things i picked up on was to send as much data to a log file as possible for troubleshooting. it really helped over time to refine down the errors and strange behaviors of many of my earlier scripts.