Search code examples
linuxcroncpanelcron-task

Is there Any File that contain Cronjob list?


I have a file read access on a website;

Is there any file (not folder for directory list) based on linux system that has cronjob list on it ?

I searched and found /etc/crontab but there is not any command here.

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

For details see man 5 crontab

Example of job definition:
.---------------- minute (0 - 59)
|  .------------- hour (0 - 23)
|  |  .---------- day of month (1 - 31)
|  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
|  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
|  |  |  |  |
*  *  *  *  * user-name command to be executed

Is there any alternative for cronjob commands file ?

(or maybe /etc/crontab is not the correct file?)


Solution

  • Yes, your crontab is (probably) stored in a file -- but there's no good reason to care about that.

    On my system, that file is /var/spool/cron/crontabs/kst, where kst is my user name. Yours may be different depending on your system (and of course your user name).

    I got this information from the crontab(1) man page (man crontab, in the FILES section).

    That file is not readable other than by the root user and if you're doing something that depends on the location of that file, you're almost certainly doing something wrong. On my system, the first line of that file is:

    # DO NOT EDIT THIS FILE - edit the master and reinstall.
    

    You should use the crontab command to manage your crontab. It will let you indirectly edit the file, and it will manage the system so that it knows when it's been updated. If you manually modify it yourself, you'll probably just create a mess.

    Use crontab -l to see your current crontab.

    You can use crontab -e to edit your crontab (it invokes your default text editor). Personally, I avoid using crontab -e. Instead, I maintain a copy of my crontab in a separate file, managed by a source control system, and then use crontab filename to install it.

    The /etc/crontab file is a system crontab, which uses a different syntax; it has a 6th field on each line specifying the user account to use to execute the command. (For a personal crontab, that's not necessary, since the command will be executed by the owner of the crontab.) There are typically a number of system crontab files; if you're curious, look in the following files and directories (these may or may not exist on your system):

    • /etc/crontab
    • /etc/cron.hourly/*
    • /etc/cron.daily/*
    • /etc/cron.weekly/*
    • /etc/cron.monthly/*
    • /etc/cron.d/*