5

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.

  • Have you searched cron's spool area? – vgoff May 11 '15 at 5:10
  • There is something in ../spool/cron/ called crontabs, but I don't know what to do with it. Can't read it any way that I have tried. – DonGroh69 May 11 '15 at 5:17
7

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 with crontab -e. The usual Linux implementation of cron stores these files in /var/spool/cron/crontabs. You shouldn't modify these files directly (run crontab -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:

May 11 07:17:01 darkstar CRON[2480]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
  • yep. it was in the system crontab. – DonGroh69 May 14 '15 at 8:13
0

May be the jobs were given by other users Try listing as

ls -lR /etc/cron*
  • Thank you, good idea. Thought I might find them, though maybe this was done as user cron, but nope. All that found was root jobs that I did not create, things like apache2, etc. – DonGroh69 May 11 '15 at 5:16
0

Global cron entries are often listed in /etc/crontab. For specifics about crontabs and their file locations try man cron and man crontab.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.