Solved

crontab: not found can't create crontabs

Posted on 2011-09-28
13
1,916 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
AWS EC2 HTTP & HTTPS 2 45
sqlldr issue 1 15
AWK: Pythagoras bp script 18 28
Interactive Powershell script to reset password age in AD 4 31
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

831 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