Solved

crontab: not found can't create crontabs

Posted on 2011-09-28
13
1,808 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Author Comment

by:inferno521
Comment Utility
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
Comment Utility
"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
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
What kind of backup are you talking about?
0
 
LVL 1

Author Comment

by:inferno521
Comment Utility
a backup via cron and ghettoVCB
0
 
LVL 68

Expert Comment

by:woolmilkporc
Comment Utility
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
Comment Utility
Here is the complete HOWTO:

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

Author Comment

by:inferno521
Comment Utility
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
Comment Utility
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
Comment Utility
That got it, thanks for all of your help
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Utilizing an array to gracefully append to a list of EmailAddresses
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
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.

728 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

9 Experts available now in Live!

Get 1:1 Help Now