nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Diff b/w /etc/crontab and /usr/bin/crontab

This is a discussion on Diff b/w /etc/crontab and /usr/bin/crontab within the Shell scripting forums, part of the Development/Scripting category; Hi, I want to know which crontab firl i should edit to schedule my script running and whats the difference ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Linux answers from nixCraft.


Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 30-01-2009, 11:57 AM
Junior Member
User
 
Join Date: Jan 2009
OS: prachi
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Prachi is on a distinguished road
Default Diff b/w /etc/crontab and /usr/bin/crontab

Hi,

I want to know which crontab firl i should edit to schedule my script running and whats the difference between processing of /etc/crontab and /usr/bin/crontab?

Thanks
Reply With Quote
  #2 (permalink)  
Old 30-01-2009, 06:27 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,707
Thanks: 11
Thanked 244 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

/etc/crontab - Configration file for cron job
/usr/bin/crontab - Binary program to edit user crontab installed in /var/spool/cron file

Basically, you need to use crontab command itself to install or edit other users job. To edit root user job:
Code:
crontab -e -u root
To edit tom users jobs:
Code:
crontab -e -u tom
/etc/crontab can be edited using vi to install system related jobs such as backup. See :
How do I add jobs to cron under Linux or UNIX oses?
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #3 (permalink)  
Old 02-02-2009, 11:22 AM
Junior Member
User
 
Join Date: Jan 2009
OS: prachi
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Prachi is on a distinguished road
Default

thanks for reply,
But still m not able to run my script through cron,I have done following things:
crontab -e root
26 21 * * * /hello.sh
This is my hello.sh file:
echo "test completed"
echo "congratulations"
mkdir gullu
where will it display the message and also no directory is made.

I also tried( * * * * * date >> /tmp/dates.txt) and this is done correctly.
Then whats wrong with my script and also do i need to write "./script" or simply "/script" to run the script?

early reply wud be appreciated
Thenks
Reply With Quote
  #4 (permalink)  
Old 02-02-2009, 02:46 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,707
Thanks: 11
Thanked 244 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

You need to specify full path for hello.sh. For e.g. if hello.sh is in /root, enter:
Code:
 26 21 * * * /root/hello.sh
Make sure script has executable permissions
Code:
chmod +x /root/hello.sh
The output is emailed to root user by default. To see it enter:
Code:
mail
To log a message to a log file use logger command in script. It will send message to /var/log/messages file.
Shell scripting: Write message to a syslog / log file
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #5 (permalink)  
Old 03-02-2009, 01:17 PM
Junior Member
User
 
Join Date: Jan 2009
OS: prachi
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Prachi is on a distinguished road
Default

thanks,my script got ececuted but i cudnt see any mail,when i type mail,its saying "no mails for root".
Also i wasnt able to open the link provided by u due to office policies and cudnt get any good information from elsewhere.
Pls tell me the how to use logger command to generate output to the console or log file.
Also i want to know that if my script simply prints "hello" on console,when i try to schedule it with cron,what will happen to the output,where does the output goes?i cant see anything on console.

Thanks in advance for your help.
Reply With Quote
  #6 (permalink)  
Old 03-02-2009, 05:50 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,707
Thanks: 11
Thanked 244 Times in 183 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Code:
logger "This is a test"
tail -f /var/log/messages
Ask them to unblock our site.
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
  #7 (permalink)  
Old 04-02-2009, 08:29 AM
Junior Member
User
 
Join Date: Jan 2009
OS: prachi
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
Prachi is on a distinguished road
Default

thanks fo rthe reply
So i can place any output from shell script through crontab in log file,that means i can not print output to console through crontab?
Like my script only prints text on console,if i run that script through crontab then what will happen to that output?
Reply With Quote
Reply

Tags
cron , cronjobs , crontab , linux , unix


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Crontab question edb75 Linux software 3 24-07-2008 03:39 PM
crontab click007 Getting started tutorials 6 19-10-2007 04:45 PM
Crontab lacloai Linux software 2 01-06-2007 03:44 AM
about crontab darknet Shell scripting 2 04-01-2007 06:01 PM
list every user's crontab script marinm Shell scripting 5 19-07-2005 11:24 PM


All times are GMT +5.5. The time now is 07:08 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38