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.
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.
I created a CRON job in the "/etc/cron.hourly" directory. Just to practice creating a CROn job I created a small BASH script that shows memory information and disk information:
I created a CRON job in the "/etc/cron.hourly" directory. Just to practice creating a CROn job I created a small BASH script that shows memory information and disk information:
When I did a ":wq" to save it and exit, I got this error:
Code:
"CRONTEST"
"CRONTEST" E212: Can't open file for writing
Press ENTER or type command to continue
Does anybody know why I got this error?
...because you don't have permissions to write to that directory or file???? Are you doing this as root? Because you're trying to put this into the SYSTEM CRON to run every hour. Your personal cron (which may or may not work, depending on if your administrator allows you to run cron jobs), is where you would put this.
Since you're not the systems administrator, based on what you've posted, you really should ask them for assistance with doing things that modify system files.
In order to run CRON jobs hourly I would have to put them in the hourly directory right?
If you are the SYSTEMS ADMINISTRATOR and want these jobs to run AS ROOT every hour, yes.
If you're NOT the administrator you can't write to that directory, and you will have to schedule your OWN jobs in your OWN cron to run every hour. AGAIN, if you're not the administrator, you need to ASK THEM for assistance with these things.
Ok, I understand now. So I logged out of SUDO and tried to create a CRON job in my own directory. I gave me the same error.Also, I'm not a systems administrator.
Ok, I understand now. So I logged out of SUDO and tried to create a CRON job in my own directory. I gave me the same error.Also, I'm not a systems administrator.
There is no logging out of sudo. Sudo is a modification to a command to give that one command root privileges. You can set it up so that it will allow you to use sudo without a password, or once the password is entered on a session you can continue to use sudo without re-entering the password, until either a timeout of the session ended.
Either case, if it is verbiage or the way each are expressing their selves we should not get overly hung up on the definition of sudo.
Instead what you should remember for this and for all cases are that when you are doing work to your system which affects the system at large, and especially if you are affecting the startup, or periodic system actions, along with working out of directories that are not your home, you should be aware that most of all those actions require superuser level privileges, however you end up obtaining them.
Therefore when you create or edit cron jobs in the future, you should remember that you'll always need to have superuser privileges.
EDIT: Although I see the concept of running a cron as a regular user is discussed in TB0ne's post. I've never done that, and probably never would try it. To me cron is used at the system level to run periodic jobs. Yes it probably can be used by a regular user, however if you have that form of maintenance requirement, I have to wonder why and what in the system is not protecting other users similarly. I.e. if it is your system alone, then I'd do it for the entire system, and thus make it as root. If it is a multi-user system, then I'd recommend to the administrator of the system that they add this for all users.
Ok, I understand now. So I logged out of SUDO and tried to create a CRON job in my own directory. I gave me the same error.
Sorry, makes no sense at all. As a regular user, you can create any files you want in your home directory, no sudo required. With sudo, you can still create a script file in your home directory.
Quote:
Also, I'm not a systems administrator.
Right, and this has been stated numerous times in the past. And AGAIN, if you are not the systems administrator, you need to WORK WITH THEM to get this done.
@MadeInGermany.....I tried everything you posted, in my HOME directory. It all worked just fine until I got to "crontab -e". It stated that Im not allowed to use this program (crontab).
@TB0ne...... I was in my HOME directory and wasn't sudo. I will work with them to be able to do this.
I created a CRON job in the "/etc/cron.hourly" directory. Just to practice creating a CROn job I created a small BASH script that shows memory information and disk information:
When I did a ":wq" to save it and exit, I got this error:
Code:
"CRONTEST"
"CRONTEST" E212: Can't open file for writing
Press ENTER or type command to continue
Does anybody know why I got this error?
well... You don't want to do that.
If you are experimenting with cron, do it as a user.
A crontab file has 6 possible entries (man 5 crontab).
Code:
field allowed values
----- --------------
minute 0-59
hour 0-23
day of month 1-31
month 1-12 (or names, see below)
day of week 0-7 (0 or 7 is Sunday, or use names)
The field not shown is the command to be run.
You would do better reading the documentation on how to use cron than trying to alter your system.
I didn't think I was altering the system in any way, I thought I was just showing information. I found out the reason why I could not create CRON jobs is because the password for the user 'oracle' is expired. Once the password is reset I will be able to do this.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.