User crontab goes where?

Chapter 11.3 explains all about the user crontab except where to create it.
I put one in my /home/Jeff directory but nothing happens.

Seems counter intuitive to put it outside of my user directory structure, won't it get wiped out next upgrade?

Puzzled.
 
I assume the crontabs go to /var/cron/tabs with the username you put there, if your username is Jeff, file name will be Jeff
 
Thanks!

I just misread it, I created my file using vi and didn't know where to put it. (forehead slap)

Jeff
 
I just misread it, I created my file using vi and didn't know where to put it. (forehead slap)
RTFM crontab(1) & crontab(5). You must not put your crontab(5) file into that directory yourself, but either use crontab(1) ( crontab -e) to edit it: the editor denoted by the EDITOR or VISUAL environment variable is invoked (default: vi(1)), or use crontab filename to "install" the file where the cron daemon expects it.
 
The crontab -e mechanism, also make sure permissions are correct so people cannot run arbitrary commands as your uid (i.e and getting write access to your personal files).
 
  • Like
Reactions: a6h
OK, I must be a moron, I still can't get this to work.

All I want to do is delete all the files in /home/Jeff/Downloads/Firefox. Sort of an automatic cache flush. I'd like it to happen every five minutes. Should be simple right?

I created the file using crontab -e, then I logged in as root and went to /var/cron and created a file called allow and put Jeff in it with no trailing space.

I tested the command rm /home/Jeff/Downloads/Firefox/* and it works from the CL.

What have I missed? Do I need a reboot to make this work?

Here is my crontab file:

Code:
#Jeff's Crontab

#

#$FreeBSD$

#

SHELL=/bin/sh

PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin

#

#minute hour    mday    month   wday    who     command

#

*/5     *       *       *       *       *       rm /home/Jeff/Downloads/Firefox/*
 
I think your crontab layout is wrong - man -S 5 crontab:

Each line has five time and date
fields, followed by a user name (with optional ``:<group>'' and
``/<login-class>'' suffixes) if this is the system crontab file, followed
by a command.

So I don't think you want that who column.
 
There are two kinds of crontab(5) files:
1. user crontabs are saved by the crontab(1) command under /var/cron/tabs/<user>, including root's. Note: batch(1) & at(1) jobs are saved under /var/at/jobs.
2. the system crontab is /etc/crontab; this one has one additional field: the who ([FONT=courier new]user[:group][/FONT]) field. Note: the periodic(8) framework is invoked via this system crontab.
 
Just a tip, don't use capital letters in your usernames. Make sure your usernames are always all lower case. Many protocols are not case-sensitive when it comes to usernames, but the system itself is. This can lead to VERY confusing problems.
 
Back
Top