How can I stop crontab from messing up this simple BASH script (and why is it happening)?

You need to give the full path to any commands executed via cron. Cron runs commands detached from any terminal which means you need to set the environment correctly. Cut is probably available but give the absolute path to iwconfig and awk.

– Jasper Aug 25 '10 at 11:23 You are correct, it needed the full path to iwconfig, I never knew! Cheers – prupert Aug 25 '10 at 11:36 glad to have helped, and yes you give absolute paths to all commands executed via cron (or just as best practice in any shell script) – ennuikiller Aug 25 '10 at 11:58.

Change the permission of this file to 777 chmod 777 /home/rupert/test. Sh Maybe this will help.

It doesn't seem to me that test has incorrect permissions (it is running...), but that the permission problem is with iwconfig. – Jasper Aug 25 '10 at 11:12 Yeah, I think permissions on the . Sh file are ok, as it does run (used chmod a+x), but as Jasper said, it might be an issue with iwconfig.. – prupert Aug 25 '10 at 11:21 You should almost never change the permissions of any file to 777.

– Dennis Williamson Aug 25 '10 at 13:45.

I don't know the exact steps to prevent this (in a clean manner) from happening (I'm not all that of a linux-expert), however, this looks like a permissions problem to me. The user as which cron jobs run isn't allowed to execute one of the commands you are letting execute. If you fix the permissions, I think it may run just fine!

Not a permission problems, turns out it was a PATH problem ;) – prupert Aug 25 '10 at 11:37 That's the one other problem that's possible in cron vs CLI (disclaimer: that I know of), I just didn't think it was being a problem here. – Jasper Aug 25 '10 at 11:45.

I have a strange issue, relating to running a BASH script via cron (invoked via crontab -e). When run from the commandline, I get the expected output of 45:70 echoed to the end of the text file. I just get the colon (:) echoed to the text file, the values SIG1 and SIG2 aren't created and I have no idea why.

Why would running via cron mess up the script? I am doing all this because I want to display the WiFi Link Quality value "46/70" on an LCD screen and the program I use does this by reading a text file. However, when run via cron, the values get lost...? I am using cut -c 9-10 and cut -c 12-13 because I was thinking the "/" might be causing an issue in the script, I'd be happy to just use cut -c 9-13, but I thought it might fix the issue, but it didn't.

Cool, thanks to you guys, I realised it was a PATH problem, simply giving the full path to iwconfig (/sbin/iwconfig) fixed it.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions