Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I like shells and scripting, but I am unsure I can give you an exact answer. A guess is you have to output from your script in a different way. Actually I made a timekeeping/alarm script that I had problems with output. I solved it by redirecting its output in the crontab differently. Look up the 'system file numbers' that you direct script output to. I suppose you want to direct it to 'standard output' or 'standard error.' If you do that the rest of your output may just show up. I have forgotten the way to redirect some output, but you use some punctuation such as '>' or '&' and then the number (representing system files such as 'standard error') is probably at the end.
Another thing I suspect is maybe cron does not work well with some of the syntax in your script. That is unlikely though. I think it is a combination of the shell and cron (since programs in your script are maybe running in the background) that has a problem doing all the output. If I did not at least indicate a few things to try, hopefully someone with much more scripting and cron experience can enlighten us.
Hey repo, your suggestion was great and even I thought it should work, but when I tried, it didn't wok too :-( .
dchmelik is correct I think. Crontab is not able to recognise some of the commands in any script.
But then I have some other scripts scheduled in crontab, which contain such commands and work well.
I'll be running in a big problem if this doesn't get solved.
Can anybody please help me? Thank you.
Sumit Dev Bharadwaj
Last edited by sumitdevbharadwaj; 04-28-2009 at 07:32 AM.
the script as written in your post above does not work, because of a syntax error. If you want to extract the second field using cut, you have to put the -f option:
Code:
x=$(tail -100 abc.sh | cut -d'|' -f2)
The script has correctly redirected the standard output to teslog1, but the standard error coming from the first line of code should have been sent to the mail of the crontab's owner. Check it using the mail command and you will find the error message.
Pardon me guys, that was my typo here. In actual script it is with -f option, as it gives correct outpout when run manually.
My problem is with crontab. There is some anomaly I am not getting to. Please post your answers as well.
With cron you have to ensure that you use the complete path for all cmds/files. This includes full path to abc.sh....
Also, ensure there is no space either side of the '=' in the assignment
x=`tail -100 abc.sh| cut -d '|' -f2`
Your version appears to have one after the '='.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.