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.
I'm trying to start a script through crond. The record in crontab is: 30 16 * * * /home/alex/razhodilim.pl 1>/dev/null
The script razhodilim.pl works perfectly if I start it manually. But cron fails to start it.
What could be the reason?
E. g. ensure that cron is running as the same user who wrote the script. Also, check that the script is readable and executable as regards permissions, by the user cron is running as.
You can also try running the script via the root user's crontab, just to debug - don't run it like that permanently - if it DOES work, it means you have some form of permissions or owership problem with the script you need to run.
Also, it seems like you're running a perl script? I see no reference to the perl binary. Remember that you might have an environment when you run the script from your terminal, but that cron will not have that same environment and path settings, e. g. it might not be able to automatically find perl to execute the script, you may need to call perl explicitly in your crontab.
The commonest reason for this type of problem is that cron sets up a restricted environment compared with the logon environment; in particular the PATH environment variable is set in a basic way. Your script can set the PATH it needs (which is robust good practice anyway).
Cron "executes" anything that it is supposed to run. The file must therefore be "executable," and furthermore it must be executable by the right user.
The documentation in man cron really is pretty good, once you've also read the various other manpages that are referenced in it. Also, if cron is unable to perform a request for any reason, it will log an error-message in a file that will (probably) be found somewhere within /var/log/messages. A command such as grep -riw cron, issued in that directory by a duly authorized user, will probably be very helpful.
Thank you all for the instructions. The file razhodilim.pl is executable, it runs without problems if started manually.
The crond is started by root.
There were no mails.
I tried to redirect the output to a file as Chris suggested but the log file is empty.
In the /var/log/cron file there is a record : USER root pid 6598 /home/alex/razhodilim.pl 1>/home/alex/error 2>&1
I also tried setting PATH variable with the paths I have in the login environment - nothing changed.
I restarted cron with logging level 12, wrote the script test.sh which echoes in /home/alex/error and scheduled it in crontab. The cron executed it. There was no log in /var/log - cron stopped logging at all.
The first line of razhodilim.pl is #!/usr/bin/perl