Solved

crontab: not found can't create crontabs

Posted on 2011-09-28
13
1,869 Views
Last Modified: 2012-08-14
Hello,

Someone a while ago created a cron job on an ESXi server.  I would like to create another one, but am not really familiar with UNIX commands.

When I enter

cd /var/spool/cron/crontabs

then enter
ls -t

I see that root is there.  I don't know if that means that the user root made this, or if this is the name of the crontab

if I enter
cat root

I see a cron job.

but if I enter:
crontab -e
or
crontab -e root

I get
-ash: crontab: not found

I am logged in as root, and I just want to create one cron job
0
Comment
Question by:inferno521
  • 7
  • 6
13 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 total points
ID: 36717493
1) ESXi doesn't have the "crontab" command.

2) ESXi rebuilds (parts of) its filesystems at reboot, so changes to the crontab will be lost anyway.

The workaround is to recreate the cronjobs at each reboot.
Please have a look at /etc/rc.local.
If there is a cronjob on your system I'm pretty sure that you'll find therein how it's being built.

It should be something like

echo '* * * * * /path/to/job ... ... ' >> /var/spool/cron/crontabs/root

wmp

0
 
LVL 1

Author Comment

by:inferno521
ID: 36717587
woolmilkporc:

thanks for the reply but I'm a bit lost.  This server hasn't been rebooted in months so I believe it is still there and the backups are still running.  I do see the rc.local and remember I'm not a command line linux guy, but when I open it by entering
cat rc.local
I see do see the
ech"what looks llike my cronjob"

So what would be the next step. Should I do something to rc.local to add another line(cron job)?  I would like to add a new cronjob and then create this on another server.  I'm willing to recreate after every reboot, we will be getting vcenter in a few months and I won't need to do this more than 2-3 times.

0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36717664
Yes,

"someone" created the existing cronjob just the way I assumed.

To create an additional cronjob you will have to do two things:

1) To make the cronjob immediately active (without a reboot, that is) edit /var/spool/cron/crontabs/root using vi and add your new statement(s).
Then issue "kill $(cat /var/run/crond.pid)"
Your job is active now.

2) To make the new job last acrosss reboots edit /etc/rc.local (again using vi) and add a line just like the existing one, namely
echo "what looks like my new cronjob" >> /var/spool/cron/crontabs/root
Save the file and you're done.

wmp
 
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 
LVL 1

Author Comment

by:inferno521
ID: 36717869
woolmilkporc:

Thanks for all of your help, but can you clarify a few things.  What is the root in /var/spool/cron/crontabs/root .  Is that the name of a cronjob or does that mean that something was created by the user root?  Also to do this on a new server, do I need to install cron?  For example I trying to schedule ghettoVCB, so I know that I will need to install that.  If I will be editing the rc.local do I need to bother with cron at all?
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36718344
"root" is the name of a file (= root's crontab)

cron is installed by default.

If you just edit /etc/rc.local the new crontab will not be built before the next reboot.
0
 
LVL 1

Author Comment

by:inferno521
ID: 36917252
woolmilkporc:

Thanks for all of your help, but I have one last question do yo know how to pick where to backup the VMs?  Will it back it up to the same data store?  I would like to send it to a different datastore.
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36917262
What kind of backup are you talking about?
0
 
LVL 1

Author Comment

by:inferno521
ID: 36917351
a backup via cron and ghettoVCB
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36917502
ghettoVCB.sh can back up to NFS or to any SAN vmfs datastore.

Configuration is done inside the script (this can be overridden by a config file using the "-f" option), so look at

VM_BACKUP_VOLUME=

or

NFS_....

wmp

0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36917595
Here is the complete HOWTO:

http://communities.vmware.com/docs/DOC-8760
0
 
LVL 1

Author Comment

by:inferno521
ID: 36917903
I just don't see where that is already entered on the backup job that was already created.  When I look at the root located at cd /var/spool/cron/crontabs its not there, and its also not in rc.local.  Do you happen to know what script I should edit to do the following?


The following variables need to be defined within the script or in VM backup policy prior to execution.

Defining the backup datastore and folder in which the backups are stored (if folder does not exist, it will automatically be created):
VM_BACKUP_VOLUME=/vmfs/volumes/dlgCore-NFS-bigboi.VM-Backups/WILLIAM_BACKUPS

Defining the backup disk format (zeroedthick, eagerzeroedthick, thin, and 2gbsparse are available):
DISK_BACKUP_FORMAT=thin

Defining the backup rotation per VM:
VM_BACKUP_ROTATION_COUNT=3
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 36918844
Does the old crontab entry contain something like "-f /path/to/a/file" ?

If so, that's the config file you're searching for
0
 
LVL 1

Author Closing Comment

by:inferno521
ID: 36918917
That got it, thanks for all of your help
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
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.

813 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now