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.
can anyone provide me the link which consists of the steps to alott cron jobs in ubuntu 9.10 server. i googled for this but can't find any appropriate solution for this.
Hi Dinesh. Your crontab entry states you would like to reboot the machine at 12:18 of every day. Is this correct?
A "problem" is that crontab has a very limited environment (not the same shell environment you get at login). Specifically, the PATH environment variable is limited to /bin:/usr/bin. Since the init command is placed in /sbin, the cron daemon cannot find it. Solution: as a general rule, you have to specify the absolute path of all the commands used in crontab, so that it should read:
Code:
18 12 * * * /sbin/init 6
Furthermore, to check if a cron job has been actually executed, you can look at the logs in /var/log (I don't know which is it exactly on Ubuntu). Finally, take in mind that the standard output and the standard error of your job (if not redirected to a file or to /dev/null) will be sent by mail to the crontab's owner (this is the default behavior): you can try to check the root's mail to see if there is a message from the cron daemon, that most likely inform you about "init: command not found".
Thank you very much for your quick reply. As you said we have to mention the path environment, what path have to be mentioned for executing backup command.
Hi Dinesh. Well done! Defining/changing the environment at the beginning of the cron script is another way to workaround the limitations. Note that, if the script calls other scripts you have only to add the export statement:
Code:
export PATH=/usr/sbin:/usr/bin:/sbin:/bin
so that the variable will be inherited from the "parent" (the main script) by its "childs".
In alternative you can "source" a login script, for example:
Code:
. $HOME/.bash_profile
or - better - you can try the -l option of bash (if your cron script is executed by bash) adding it to the she-bang:
Code:
#/bin/bash -l
This means that the shell is invoked as a login shell.
A last note: many insights about the crontab limitations are provided by the following manual pages:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.