Crontab issues

For basic crontab configurations please click here
Issue1:How to deny a user not to use his/her crontab to schedule his jobs
there is seperate contab file for dening for user open and file and specify users name in that file
#vi /etc/cron.deny
Issue2:Display cron jobs for all users
When migrating from one system to another it is good to know if there are cron jobs from other users on the system, here is how to display all of them:
1. for i in `cat /etc/passwd | cut -f 1 -d ':'`; do crontab -u $i -l; done;
for user in $(cut -f1 -d: /etc/passwd); do crontab -u $user -l; done
will loop over each user name listing out their crontab. The crontabs are owned by the respective users so you won't be able to see another user's crontab w/o being them or root.
ISSUE3:Using crontab as alaram? I want a song played on every weekday at 5AM and i dont want it in weekends
here is the solution you requred mplayer or vlc player to do this which will support CLI execution.
mplayer /music.mp3 & /dev/null&
00 05 * * 1-5 mplayer /music.mp3 & /dev/null&
ISSUE4:I have written a shell script that works from console but does not work via crontab.
This type of issues will occure in four situations
1. when there is some env variable issue
2. when crontab service it self not running in your system
check wether crontab service is running or not
#pgrep cron
3. When there is some issue with cron job contents(like check for spaces and empty lines remove all of them) 
if you didnt find any cron process running please start the crontab service as below
#service crond restart
4. when you are executing script or command please specify the full path to that command
ISSUE5:I am running a script , working very fine on cmd prompt. The problem is that when I open do crontab -e its giving some weired values like below 
baafh-99.03# crontab -e





how to resolve this issue?

This type of issue will come when the default editor is not set to VI to do this just execute the below commands

export EDITOR

Some important files and command for crontab
/var/cron/log file is used for logging some crontab messages, so very much useful for debugging crontab issue
/etc/crontab is the main configuration file for crontab where you can see crontab settings and all crontab hourly,monthly etc folders in this file
/etc/cron.monthly these folders are used for keeping scripts in this folders so that on that perticular day/time the script will execute.

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Related Posts by Categories



    Translate this page


    The Linux Juggernaut | Copyright 2006-2009 Surendra Kumar Anne | Surendra's Home Page | Give us feedback how we are doing, Click here