Crontab issues

0 comments


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;
or
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#
baafh-99.03# crontab -e
1063

?

?

?

?

?
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

EDITOR=vi;
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.hourly
/etc/cron.dialy
/etc/cron.weekly
/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
  • Linux interview questions.

    0 comments

    what is the difference between soft link and hard link?
    what are the advantages with NFS?
    What is difference between LILO and GRUB?
    How you will troubleshoot if boot partation is missing?
    What is crontab?
    How you will install MYsql in different ways?
    What is the difference beween Mysql5.0 and 4.0 versions?
    the host is unreachable how you will resolve this issue?

    there is no firewall the host is in same network and dns server is working fine
    ?
    what is mii tool will do?
    what is the advantage of lsof command?
    How you can compile kernel?
    What is CVS server?
    what are your day today activity?
    how you will create users on NIS server when the server is in production envernoment?
    Actually there is one partaion with 20gb mounted on /data. Users are unable to create files and data due to disk full so when you logged in to server and checked the space by using du -k its showing.

  • Like the post? Please Subscribe to free RSS feed to get updates
  • IPTABLES BASICS

    0 comments

    IPtables is vast topic which can not be dealt in one post I will be posting this IPtables in different posts but will link all of them

    IPtables basics

    Iptables is a securit module in Linux kernel, this Iptables can be used a firewall(filter table),Internet sharing(NAT table),For altering Type Of Service(mangle table) and for non tracking purpose(Raw table)

    Firewall definition:

    A firewall is a security system consisting of a combination of hardware and software that limits the exposure of a computer or computer network to attack from crackers; commonly used on local area networks that are connected to the internet. This is acheived by Filter table

    Internetsharing definition:

    An Internet standard that enables a LAN to use one set of IP addresses for internal traffic and a second set of addresses for external traffic. A NAT box located where the LAN meets the Internet makes all necessary IP address translations.

    Mangling definition:

     Mangling is defined as changing the Type of service value in IP header packet to get the desired values such as decreasing latency(for example telnet,ssh should required less latency) etc. This table is used for imporving some services performance

    Non tracking packets definition:

    Most of the system/network activitis are logged in some logs, if we want our packets to be not monitored we can use this table, This raw table(which is introduced in 2.6 version linux kernel for some special feature) will set value on each packet not to track where this packet is coming and going.


    IPtables is nothing but a set of tables

    A table is set of chains and target values.
    A chain is nothing but a rule on a packet wether to forword or drop or Reject etc
    A rule is nothing but setting a criteria for packet.

    Iptables will work on targeting IP packets and chains
    These targets may be

    1. ACCEPT
    2. DROP
    3. REJECT
    4. SNAT
    5. DNAT
    6. NOTRACK
    7. BALANCE
    8. CLASSIFY
    9. CLUSTERIP
    10. CONNMARK
    11. DSCP
    12. ECN
    13. LOG
    14. MARK
    15. MASQUERADE
    16. MIRROR
    17. NETMAP
    18. REDIRECT
    19. ROUTE
    20. SET
    21. TCPMSS
    22. TOS
    23. TRACE
    24. TTL
    25. ULOG

    these chains may be
    1. INPUT (for packets destined to local sockets),
    2. FORWARD (for packets being routed through the box),
    3. OUTPUT (for locally-generated packets)
    4. PREROUTING (for altering packets as soon as they come in),
    5. POSTROUTING (for altering packets as they are about to go out).
    in next post I will be giving some explination to this targets and chains with some practical exampls, thanks for reading the blog and commenting.

  • Like the post? Please Subscribe to free RSS feed to get updates
  • Archive

    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