Solved

cron????

Posted on 2002-04-25
11
342 Views
Last Modified: 2010-04-22
but before we use cron to test the email, we just simply want to copy the file from one particular file e.g. file.txt to backup.txt,
but it also not function. maybe I now attach the file, so can u please help me to take a look, to see whether it has problem??


here are the steps we have done:
1. create a txt file called "file.txt"
2. create a crontab file called "mycronfile" and the command line inside the file is "7 18 25 4 4 cp ../usr/test/file.txt ../usr/test/backup.txt
"
3. put "mycronfile" to the folder ./etc/cron.d
4. In Konsole typed "crontab mycronfile"
5. But no backup.txt is created

really thanks a lot.
0
Comment
Question by:sandysansan
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 51

Accepted Solution

by:
ahoffmann earned 25 total points
ID: 6968794
did you wait 'til 18:07 ?
0
 

Author Comment

by:sandysansan
ID: 6972171
yup, I wait until 18:07, is there any problem??
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6972987
if cron did not produce what you want at 18:07, then check roots mail, cron mails errors to root
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

Author Comment

by:sandysansan
ID: 6975273
I have also checked mail for root, but "No mail for root"  displayed only.
Is there any special setting needed before I can checked email?
0
 
LVL 5

Assisted Solution

by:bryanh
bryanh earned 25 total points
ID: 6982523
First of all, there are various cron facilities, and the one I use is probably not the one you use, so my advice could be a little off.

Cron traditionally mails all output (error messages and otherwise) to the user for whom the event was run.  Which may or may not be root.  If it isn't configured properly, it may be unable to do this mailing, though.  Another source of information about cron is syslog.  Syslog messages often go the file /var/log/messages or other files in /var/log.

As a check on what you're doing, you should run 'crontab -l'.  If you successfully installed that cron file, crontab -l should list it back to you.

And to eliminate some variables and facilitate your testing, you should make that entry * * * * * instead of 7 18 25 4 4.  That means "run once every minute."

Do you have any evidence the cron daemon is running at all?
0
 
LVL 2

Expert Comment

by:pheur
ID: 6983096
Just some notes:
- no nees to put manually the file in /etc/cron.d/. Just do
"crontab filename" or "crontab -e" and type the line there.
- specifying ALL the 5 time parameters doesn't make much sense.  Generally only some are specified, the rest being replaced by "*".

And now the fatal error: you used relative paths. DON'T ! use full paths, or use scripts that chdir to the desired directory before using relative paths.

--
Radu-Adrian Feurdean
Brainbench Linux MVP
0
 

Author Comment

by:sandysansan
ID: 6986960
I have typed crontab -l
and the ouput is:

# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.1276 installed on Fri May  3 02:29:53 2002)
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
* * * * * root/test/test.sh

In test.sh:

#!/bin/bash
echo "`date`"
echo "--Testing cron -> mail"

I have also typed "crontab -e" and type
* * * * * root/test/test.sh

After exit to [root@XXXXX]#
I typed "mail" but display "No mail to root"

What is the problem?
anything I am wrong......Thanks a lot for your kindly help
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6987089
silly question: did you miss a leading slash in
   root/test/test.sh
0
 
LVL 5

Expert Comment

by:bryanh
ID: 6987735
You could eliminate a few variables from this test by using /bin/touch /tmp/cronisalive in place of root/test/test.sh.
That way, you're not depending on mail working, for one thing.
(but make sure you have a /bin/touch -- I'm not sure where it conventionally lives).

I still wonder if you have any evidence crond is running.  Do you see it in a ps -ax listing?  Do you see any messages from it in any log files?

Have you tried killing and restarting crond?
0
 
LVL 20

Expert Comment

by:jmcg
ID: 9901600
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: ahoffmann {http:#6968794} & bryanh {http:#6987735}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question