?
Solved

Error Creating crontab

Posted on 2009-02-09
25
Medium Priority
?
1,962 Views
Last Modified: 2013-12-06
Hi,

I am new to Debian/Linux

I want to import crontab.
I am logged in as particular user

When I try to execute my command crontab crontab.2

I get an error

abcdmcc@defg-pbhi5:~$ crontab crontab.2
crontab: error renaming crontabs/tmp.5q9na1 to crontabs/abcdmcc
rename: Operation not permitted
abcdmcc@defg-pbhi5:~$

My File crontab.2
 
#
# Start up cmc applications every 5 minutes
4,9,14,19,24,29,34,39,44,49,54,59 * * * * /usr/local/applic/cmc/exe/start > /dev/null 2>&1
#
# Start up the cleaner process every hour
0 * * * * /usr/local/applic/cmc/exe/cleaner > /dev/null 2>&1
#
 
# Creates User Registration Request Daily at 6AM
0 6 * * * perl /usr/local/applic/cmc/admin/createTestFilesAuto.pl RegistrationRequest_v2_6.xml
# Creates Password Reset Request Daily at 12PM
 0 12 * * * perl /usr/local/applic/cmc/admin/createTestFilesAuto.pl MessageRequest_v1_2_1.xml ChangePassword
# Creates Alert 10 Daily at 04PM
0 16 * * * perl /usr/local/applic/cmc/admin/createTestFilesAuto.pl MessageRequest_v1_2_1.xml Alert10 No Yes
#

Open in new window

0
Comment
Question by:tia_kamakshi
  • 10
  • 9
  • 5
  • +1
25 Comments
 
LVL 29

Expert Comment

by:fosiul01
ID: 23590632
Does this perticuler user has root permission to copy ??

have you tryed with root username ??
0
 
LVL 2

Expert Comment

by:barkermn01
ID: 23590736
This is because, you don't have permission to write to the file location weather you have permission.

A Root Account can access every file,

a None SU Account cannot access scripts outside of your directory in Linux
/home/*Username*/

Where *Username* is your username

This prevent you from hacking a Server. Also how are you adding these i don't think crontab can open its self using a different file i think it block it but run all of those script as there own cron job and it should work fine
0
 

Author Comment

by:tia_kamakshi
ID: 23591414
Ok, I got your point.

Then how can I create cron or schedular for particular user. When I am logged in as root user

Many Thanks for your co-operation
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 29

Expert Comment

by:fosiul01
ID: 23591590
Hi yah

about permission i might not be 100% true

because in my debain pc i can create crontab like the way you are

crontab crontab.2

without any problem
here something else creating the permission problem

crontabs/tmp.5q9na1 to crontabs/abcdmcc

do you have any directory call crontab ??

like my one dong like this
tmp/tmp.5q9na1 to crontabs/abcdmcc

your one is tryign to create tmp crontab file in /crontabs directory

0
 

Author Comment

by:tia_kamakshi
ID: 23591773
No I don't have crontab directory on the location where I am running this command...
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 23591931
but as normla user
if you do

crontab - e : it will allwo you to insert crontab rules

can you do that ?? or its giving same problem ??
0
 

Author Comment

by:tia_kamakshi
ID: 23591980
yes, i can enter using crontab -e. But I find hard working with this editor.
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 23592103
can you do this please

locate crontabs


see if you see something call crontabs
0
 

Author Comment

by:tia_kamakshi
ID: 23592172
Yes I have executed command and I got the below result

abcdmcc@defg-pbhi5:/home/tgfr/out$ locate crontabs

/var/spool/cron/crontabs
/var/spool/cron/crontabs/abcdmcc
/var/spool/cron/crontabs/root

Thanks for your co-operation
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 23592658
hi pls allow me couple of hous. But can u check permision of those dirctory.
0
 
LVL 23

Expert Comment

by:Maciej S
ID: 23601104
"Then how can I create cron or schedular for particular user. When I am logged in as root user"
crontab -u user -e

"yes, i can enter using crontab -e. But I find hard working with this editor."
If your want to use some other editor to edit your crontab with -e option, set EDITOR variable and point to editor of your choice (ie: EDITOR=nano crontab -e)
or:
export EDITOR=nano (you can put this to /etc/profile or similar one to 'save' this setting).
crontab -e

I'm not sure about debian, but in gentoo, you need to add user to "cron" group if you want to give such user possibility to use cron (relog after that).
Or, you may also check /etc/cron.allow and/or /etc/cron.deny files.
If cron.allow exists, you need to put into this file user's username to allow him/her to use cron.
If cron.allow doesn't exist, but there is cron.deny, you have to make sure, that this file doesn't contain your user's username.
0
 

Author Comment

by:tia_kamakshi
ID: 23611082
Hi,
 
 I don't know the what the problem is
 
 My editor is GNU nano 2.0.2
 
 On the top of the file it is wriiten
 
 GNU nano 2.0.2        File: /tmp/crontab.Yryf5C/crontab             Modified
 
 But I cannot see crontab.Yryf5C in the tmp directory

If I see tmp directory

I have

abcdmcc@defg-pbhi5:/tmp$ ls c*
crontab.F5END0:
crontab

crontab.PZt7ab:
crontab
abcdmcc@defg-pbhi5:/tmp$ ls c* -l
crontab.F5END0:
total 4
-rw------- 1 abcdmcc crontab 389 2009-02-09 21:30 crontab

crontab.PZt7ab:
total 4
-rw------- 1 abcdmcc crontab 244 2009-02-09 20:53 crontab
abcdmcc@defg-pbhi5:/tmp$


I hav emodified my cron and as instructed below of the page  

                                [ Read 7 lines ]
^G Get Help  ^O WriteOut  ^R Read File ^Y Prev Page ^K Cut Text  ^C Cur Pos
^X Exit      ^J Justify   ^W Where Is  ^V Next Page ^U UnCut Text^T To Spell

I press ctl + X

then I get

Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?
 Y Yes
 N No           ^C Cancel


then I press Y

then I get

File Name to Write: /tmp/crontab.Yryf5C/crontab
^G Get Help         ^T To Files         M-M Mac Format      M-P Prepend
^C Cancel           M-D DOS Format      M-A Append          M-B Backup File

I am still not able to save cron
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 23611115
look at your permission

-rw------- 1 abcdmcc crontab 389 2009-02-09 21:30 crontab

it has only access by root, but no other user
you need to change permisison for tmp directory
as a root :

chmod 777 tmp
then try to save


0
 
LVL 29

Expert Comment

by:fosiul01
ID: 23611130
sorry, at first check the permission of tmp directory

with ls command

you can change directory prmission 777 if it does not hae

or if you can pos

ls | grep tmp

it would of show you the permisison of tmp
0
 
LVL 23

Expert Comment

by:Maciej S
ID: 23611134
It should be chmod 1777 /tmp, rather than just 777.
0
 

Author Comment

by:tia_kamakshi
ID: 23611167
Ok, If I donot wanted to change the tmp folder permission

and I can access server as root
Then even crontab -u username -e

is still gives the same prob

Then How can I save cron for particulR USER
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 23611190
by default every system has this permission for tmp

-bash-3.2# ls -l | grep tmp
drwxrwxrwt 13 root root  4096 Feb 11 10:18 tmp

and as Oklit said to add 1777 [ striky bit 1] so that this folder would not be delete by any other user rather then superuser

its totaly safe

0
 
LVL 23

Expert Comment

by:Maciej S
ID: 23611228
/tmp should have by default 1777 set (lit. it is drwxrwxrwx). If it doesn't have such permissions set, you should set it. (you can check this with command: ls -ld /tmp).

When you make sure, that /tmp has correct permissions, run this commands:
(as root): crontab -u abcdmcc -r
I assume, that your user's username is abcdmcc. This command will remove this user's crontab.

Then, run as user:
crontab -e
Add some simple cronjob (ie. 1 1 * * * /bin/date)
Save the file.

Did it work, or still have problems after issuing above commands?
0
 

Author Comment

by:tia_kamakshi
ID: 23611969
Thanks for your quick responses

I have changed the permission of tmp to 1777 from root permission

Then I logged in my user and su to user abcdmcc

I get error says rename: Operation not permitted

Please see the details below

abcdmcc@defg-pbhi5:~$ crontab crontab.2
crontab: error renaming crontabs/tmp.pAtatb to crontabs/abcdmcc
rename: Operation not permitted

abcdmcc@defg-pbhi5:~$ crontab crontab.2
crontab: error renaming crontabs/tmp.P1vcba to crontabs/abcdmcc
rename: Operation not permitted

abcdmcc@defg-pbhi5:~$ cd /tmp/
abcdmcc@defg-pbhi5:/tmp$ ls -l
total 856
drwx------ 2 abcdmcc crontab   4096 2009-02-09 21:25 crontab.F5END0
drwx------ 2 abcdmcc crontab   4096 2009-02-11 13:19 crontab.fi9hQh
drwx------ 2 abcdmcc crontab   4096 2009-02-09 20:53 crontab.PZt7ab
drwx------ 3 root    root      4096 2008-10-22 10:02 gconfd-root
-rw-r--r-- 1 root    root    623706 2009-02-04 18:05 log.txt
srwxr-xr-x 1 root    root         0 2008-09-22 13:50 mapping-root
drwx------ 2 root    root      4096 2008-10-22 10:02 orbit-root
-rw-rw-rw- 1 root    root    217757 2009-02-03 13:35 vsftpd.log
abcdmcc@defg-pbhi5:/tmp$ cd ..
abcdmcc@defg-pbhi5:/$ pwd
/
abcdmcc@defg-pbhi5:/$ ls -l
total 96
drwxrwxrwt   9 root root        4096 2009-02-11 14:48 tmp
abcdmcc@defg-pbhi5:/$


Yes, I cannot delete any existing crons as this is my live production server

Thanks again for your help giving
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 23612068
Ok can you tell me what the permission on this one

/var/spool/cron/crontabs/abcdmcc

here go to
var/spool/cron/
ls

also
var/spool/cron/crontabs/
ls
0
 
LVL 23

Expert Comment

by:Maciej S
ID: 23612106
You said, you are able to edit this cron as root, right?
If so, first make backup of your current cron. Run (as root): crontab -u abcdmcc -l > crontab.bak
Then, remove this crontab (again - as root) with command: crontab -u abcdmcc -r, then try to add something (as user abcdmcc) with crontab -e.
If this doesn't work, restore your previous crontab: as root, run: crontab -u abcdmcc crontab.bak

Last thing I can think of, is that you have wrong permission on crontab binary.
Paste here output of command: ls -l `which crontab`
0
 

Author Comment

by:tia_kamakshi
ID: 23612131
Here it is

defg-pbhi5:/var/spool/cron/crontabs# ls -l
total 8
-rw-r--r-- 1 root root     438 2008-04-09 11:59 abcdmcc
-rw------- 1 root crontab 1778 2009-02-06 14:54 root
defg-pbhi5:/var/spool/cron/crontabs# who am i
root     pts/6        2009-02-11 15:07 (10.1.60.6)
defg-pbhi5:/var/spool/cron/crontabs#

defg-pbhi5:/var/spool/cron/crontabs# cd ..
defg-pbhi5:/var/spool/cron# ls
atjobs  atspool  crontabs
defg-pbhi5:/var/spool/cron# ls -l
total 12
drwxrwx--T 2 daemon daemon  4096 2008-03-06 09:52 atjobs
drwxrwx--T 2 daemon daemon  4096 2006-01-03 07:15 atspool
drwxrwx--T 2 root   crontab 4096 2009-02-11 14:49 crontabs
defg-pbhi5:/var/spool/cron#

0
 
LVL 29

Accepted Solution

by:
fosiul01 earned 1000 total points
ID: 23612264
ommm

if you check this file

-rw-r--r-- 1 root root     438 2008-04-09 11:59 abcdmcc

it has abcdmmcc user only r permission

 and the error
crontab: error renaming crontabs/tmp.pAtatb to crontabs/abcdmcc

which is trying to rename from crontabs to crontabs/abcdmcc
but this crontabs/abcdmcc got only Read permission,

hence it could be the problem

go to /var/spool/conrtab
and change the permision of directory from root to abcdmcc

chown abcdmcc[username] filename abcdmcc[filename]

then do

chmod 755 filename abcdmcc

omm should work,

i am  trying to give solution from the problmes points of view, but tel me if it does make sense
0
 
LVL 23

Assisted Solution

by:Maciej S
Maciej S earned 1000 total points
ID: 23612422
No, no, no :) Don't do this :)
This file should be owned by root, not the user (although this may work, but it really should be owned by root).

tia_kamakshi, run: ls -l `which crontab` and paste output here. There can be some problem with permissions of your crontab binary. It should be suid root, or sgid cron/crontab - depending on distribution. I don't have debian installed at this time (maybe I will install it in the evening), but on slackware (rather old one - something about 10.0 version) it is suid root, and group is bin. On gentoo and ubuntu it's owned by root, and sgid to crontab group.
0
 

Author Closing Comment

by:tia_kamakshi
ID: 31544529
Many Many Thanks for your great help in fixing it. It is fixed. It was the permission problem and you helpmed me in fixing this
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating a Samba server for a small office. Ubuntu Linux and Samba can breathe new life into a retired PC and save an office money on new hardware/software. Our example server will have two hard disks, one exclusively for storing shared data. …
Users are often faced with high disk consumption without really knowing where the largest amount of data resides. Disk Usage Analyzer (aka Baobab) is is a graphical, menu-driven application to analyse disk usage in any Gnome environment and can e…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question