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!

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.

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.

I can run the script manually via the shell but I want to set up my Crontab to do this for me. I am tired of these tedious tasks and that is what Cron is for right? Please if anyone can help I would be grateful

You have to say /bin/cp ... plain cp doesn't work. That's probably ALL
that's wrong. Here's some other info you didn't ask for.

Setup a cron job
crontab -urichard -l (to list) and crontab -urichard -e (to edit)
If crontab doesn't allow you to do this, put the name richard in
the file. /etc/cron.allow (create the file if you need to). You do not
need to stop and start cron ... at least not when using crontab, possibly
when creating the cron.allow file.

Here is a working crontab file
# Beginning of crontab file
SHELL=/bin/bash
# Select a shell to use
* * * * * /bin/echo "One minute has elapsed">>/home/richard/rscron.log
# Output this message every minute. Note that have to use a path
# explicitly for echo as the usual path is not what cron uses. Without the
# /bin, this script produces no output.

Hmmm. If you _really_ want to put your Script in the global crontab, don't forget to set the username. Cron normally runs as root and also all the scripts it will run for you - this is bad security. So set the username, either "root" or better a non-privilleged user.

But I suggest to use the way described above. If it's normally the job of your user, then use a personal crontab to do the job.

Thank you for all of the help ...
I tried this one ... crontab -uroot-l (to list) and crontab -uroot-e (to edit) , and the shell said "no crontab for user root" How would I make a crontab for the specific user? What is a global crontab and why is it bad? This is the one I am using right? Is it the file in the root file system? How could I limit to a specific user? I am so confused.

I just tried the following on my system and got a result similar to yours. Here it is:

"garage:/etc# crontab -uroot -l
You (root) are not allowed to use this program (crontab)
See crontab(1) for more information".

Here's what I think is happening. Linux is trying to protect you from running crontab as root. It really wants you to run it as some other user. Here is how you do that:

I'll assume you have a user on your system called adam.

Then you edit /etc/cron.allow (creating it if it doesn't exist) and add
a line that simply says "adam". (No quotes). My /etc/cron.allow consists of a single line, "richard". That's it.

Then you can crontab -uadam -e. You will notice that you are dropped into an empty file, you aren't messing with that crontab "minute", "hour" day file. That's the one that aeichner called "global". Go look at the example crontab file I showed in my last post. I specifically had it write a message once a minute so I wouldn't have to wait too long to see if it was working! Once you've got that, you should be able to do whatever you want.

do an "ls -l `which reboot'" ( without the double quotes, keep the backticks ) and make sure you have permission to run the reboot command. if you don't, then what I would do is use chmod to let you do that, and then try it from the command line to make sure it works. Another option for reboot is "shutdown -r now", which also requires that you have permission to run it.

Instead of changing the ownership of the file, is it possible to add my user "will" into the group root? is it recommended to do so?

do an "ls -l `which reboot'" ( without the double quotes, keep the backticks ) and make sure you have permission to run the reboot command. if you don't, then what I would do is use chmod to let you do that, and then try it from the command line to make sure it works. Another option for reboot is "shutdown -r now", which also requires that you have permission to run it.