Solved

Crontab Problem

Posted on 2013-01-21
21
1,073 Views
Last Modified: 2013-01-21
When i try to run crontab -l from the root log prompt in i am told it is not available

However, if i navigate to /etc/crontab its there

Most of my servers respond to the crontab -l command when at the root login prompt.  Is there something i need to install to get the rest of the servers to work this way?
0
Comment
Question by:deklinm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 9
  • 6
  • 5
  • +1
21 Comments
 
LVL 31

Expert Comment

by:farzanj
ID: 38801603
Those settings are always there but your personal cron entries, in this case root's cron entries should be present in

/var/spool/cron
folder


Take a look, I didn't have any cron entry and the I created an entry.
[root@labvm3 ~]# crontab -l
no crontab for root
[root@labvm3 ~]# ls /var/spool/cron/
[root@labvm3 ~]# crontab -e
no crontab for root - using an empty one
crontab: installing new crontab
[root@labvm3 ~]# crontab -l
* * * * 1 echo "***"
[root@labvm3 ~]# ls /var/spool/cron/
root

So the file is
/var/spool/cron/root

You are looking at the system file.
0
 
LVL 9

Expert Comment

by:user_n
ID: 38801638
try to see whether the cron folder is in your path enviroment variable
http://en.wikipedia.org/wiki/Environment_variable
0
 

Author Comment

by:deklinm
ID: 38801642
Below is what happens when i try to run crontab -l

[root@server3 ~]# crontab -l
-bash: crontab: command not found
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 68

Expert Comment

by:woolmilkporc
ID: 38801643
/etc/crontab

is the system crontab, not root's crontab!
0
 
LVL 31

Expert Comment

by:farzanj
ID: 38801645
Issue command
/bin/crontab
0
 
LVL 31

Expert Comment

by:farzanj
ID: 38801648
Your root user probably doesn't have /bin in its path OR you did

su

instead of doing

su -
0
 
LVL 9

Expert Comment

by:user_n
ID: 38801652
crontab folder should be in path variable or you have to write the full path to the crontab -l
http://www.math.iitb.ac.in/resources/manuals/Unix_Unleashed/Vol_1/toc.htm
0
 

Author Comment

by:deklinm
ID: 38801664
Results

[root@server3 ~]# /bin/crontab
-bash: /bin/crontab: No such file or directory
0
 

Author Comment

by:deklinm
ID: 38801670
No i am getting permission denied.

I am logged in as root.

[root@server3 ~]# /etc/crontab
-bash: /etc/crontab: Permission denied
0
 
LVL 31

Expert Comment

by:farzanj
ID: 38801681
NO

I SAID BIN NOT ETC

/bin/crontab

If this still doesn't resolve the problem:

Please issue command
rpm -q cronie

If you don't have this RPM install it by issuing command

yum -y install cronie
0
 

Author Comment

by:deklinm
ID: 38801697
[root@server3 ~]# rpm -q cronie
package cronie is not installed
[root@server3 ~]# yum -y install cronie
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.corenetworks.net
 * extras: mirror.sanctuaryhost.com
 * updates: mirror.serversurgeon.com
Setting up Install Process
No package cronie available.
Nothing to do
0
 
LVL 9

Expert Comment

by:user_n
ID: 38801706
The User's Shell Startup File: .profile Under each Bourne shell user's home directory is a file named .profile. This is where a system administrator or user (if given write permission) can make permanent modifications to his shell environment. To add a directory to the existing execution path, just add the following as line into .profile.

PATH=$PATH:/sql/bin ; export PATH
0
 
LVL 31

Expert Comment

by:farzanj
ID: 38801711
Sorry, on Centos it is

/usr/bin/crontab

I was on Fedora.
0
 

Author Comment

by:deklinm
ID: 38801715
[root@server3 ~]# /usr/bin/crontab
-bash: /usr/bin/crontab: No such file or directory
0
 
LVL 31

Expert Comment

by:farzanj
ID: 38801718
However, cronie is the correct package for CentOS
0
 
LVL 31

Expert Comment

by:farzanj
ID: 38801725
Ok, looks like you really don't have this package installed and you don't seem to have it from yum either.  Do you have CD/DVD?
0
 

Author Comment

by:deklinm
ID: 38801735
ok..i got crontab installed using the code below

    yum install vixie-cron crontabs
    /sbin/chkconfig crond on
    /sbin/service crond start


Now i am receiving an error that states

[root@server3 ~]# crontab -l
no crontab for root
0
 
LVL 31

Accepted Solution

by:
farzanj earned 500 total points
ID: 38801742
This error is normal.  See my very first comment.  It simply says that you have no entries in your cron
0
 
LVL 31

Expert Comment

by:farzanj
ID: 38801746
Also issue command

chkconfig crond on

So that it stays on after reboot.
0
 
LVL 9

Expert Comment

by:user_n
ID: 38801794
0
 
LVL 9

Expert Comment

by:user_n
ID: 38801799
Login as the adm user and use crontab -e to edit the crontab file to activate the daily accounting functions. By editing the /var/spool/cron/crontabs/adm file, you are allowing cron to control the periodic collection and reporting of statistical data. See the example of the crontab entries for runacct, dodisk, ckpacct, and monacct below:

10 23 * * 0-6 /usr/lib/acct/runacct 2>/usr/adm/acct/nite/accterr > /dev/null
0  23 * * 0-6 /usr/lib/acct/dodisk > /dev/null 2>&1
0  *  * * *   /usr/lib/acct/ckpacct > /dev/null 2>&1
15 4  1 * *   /usr/lib/acct/monacct > /dev/null 2>&1
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
lunix and unix command 21 154
Samba Question 11 137
CentOS 7 Linux for HP DL380 G4 32Bits 7 103
RPM creation 6 48
In my business, I use the LTS (Long Term Support) versions of Linux. My workstations do real work, and so I rarely have the patience to deal with silly problems caused by an upgraded kernel that had experimental software on it to begin with from a r…
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

732 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