I am running Raspbian on a Pi and installed cron to schedule a job. I wrote a Python script and I set it to run every 5 minutes. The job is happening every 5 minutes, no problems, but when I run crontab -l
as root
and pi
, it says there are no jobs. When I run crontab -e
as root
and as pi
they are blank.
I honestly can't remember the exact details of when I set up the job. I know I wrote a line on a document that was formatted like a crontab
and I am pretty sure it was done as root
.
I have discovered this as I was going to add some more jobs, and would like to locate the other one I made before I get going on adding more.
Best Answer
There are two lists of scheduled tasks (crontabs).
Each user (including root) has a per-user crontab which they can list with
crontab -l
and edit withcrontab -e
. The usual Linux implementation of cron stores these files in/var/spool/cron/crontabs
. You shouldn't modify these files directly (runcrontab -e
as the user instead), but it's safe to list them to see what's inside. You need to be root to list them.There is a system crontab as well. This one is maintained by root, and the jobs can run as any user. The system crontab consists of
/etc/crontab
and, on many systems, files in/etc/cron.d
. These files have an additional column: after the 5 date/time fields, they have a “user” field, which is the user that the job will run as. It's common to set up/etc/crontab
to run scripts from directories/etc/cron.hourly
,/etc/cron.daily
, etc. and that's how it's done on Raspbian.So look in all these places:
/var/spool/cron/crontabs/*
(you need to be root for this one),/etc/crontab
,/etc/cron.*
.You can also get information in the system logs. They won't tell you where the job was listed, but they tell you exactly what command is being executed, so you can search for the command text. For example, this is the entry that runs commands in
/etc/cron.hourly
every hour: