The cron command is the clock daemon that executes commands at specified dates and times.
Question: I developed my script and it runs flawlessly, but when I insert it into the crontab, it fails.
Answer: The cron is executing with the root user id, and your environment is not set up correctly.
Fix: Investigate the use of the user cron feature or use the su command to execute your script. See man su. Essentially cron runs your script under the environment of a user.
Applications and user developed scripts should never be run under root, as they should have their own user environment.
If the script is very complex, you can set up a special user, and code the script in the user profile, then simply log into that user to execute. cron entry simply would be su - <user>. If you look at some of the UNIX special users, you will notice that the OS does it this way.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.