Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
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.
When you run things from CRON your environment variables are different then when you run them directly.
Most likely /home/cwc/scripts/logfile.sh is relying on one or more of these environment variables. Could be that PATH is different, or something that normally gets set in .bashrc ...
Edit: Ignore this comment. I missed that you posted the contents of the script. Habitual is right ...
Adding sh before the script is also not necessary, as the first line in your batch file has specified that already.
I tried it on my computer and it seems to work as well. In order to debug it any further you need to give more info. For example, what is the expected output, what output are you getting. Are you getting a separate file for each minute. Are they all the same?
One comment is that you've specified /bin/sh, but are using bash specific commands like $(). You should use /bin/bash instead. It might work the way you've written it, but it doesn't have to ...
You could use "#!/bin/bash -l" on the first line of your script. Though I see nothing that would require you to use the login option. It's good to read "man 5 crontab" and "man crontab" to understand how the execution occurs including the environment.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.