Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2345
  • Last Modified:

crontab: not found can't create crontabs

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
inferno521
Asked:
inferno521
  • 7
  • 6
1 Solution
 
woolmilkporcCommented:
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
 
inferno521Author Commented:
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
 
woolmilkporcCommented:
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 
inferno521Author Commented:
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
 
woolmilkporcCommented:
"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
 
inferno521Author Commented:
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
 
woolmilkporcCommented:
What kind of backup are you talking about?
0
 
inferno521Author Commented:
a backup via cron and ghettoVCB
0
 
woolmilkporcCommented:
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
 
woolmilkporcCommented:
Here is the complete HOWTO:

http://communities.vmware.com/docs/DOC-8760
0
 
inferno521Author Commented:
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
 
woolmilkporcCommented:
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
 
inferno521Author Commented:
That got it, thanks for all of your help
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now