Cronjob testing


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Cronjob testing
# 1  
Old 12-22-2010
Cronjob testing

I've been puzzling over cronjobs for the last few hours. I've read documentation and examples. I understand the basics and concepts, but haven't gotten anything to work. So I would appreciate some help with this total noob dilemma.

The ultimate goal is to schedule the execution of a django function every day. Before I get that far, I want to know that I can schedule any old script to run, first once, then on a regular basis.

So I want to:
1) Write a simple script (perhaps a bash script) that will allow me to determine that yes, it did indeed run successfully, or that it failed.
2) schedule this script to run at the top of the hour

I tried writing a bash script that simple output some text to the terminal:
#!/bin/bash
echo "The script ran"
Then I dropped this into a .txt file
MAILTO = *****.******@gmail.com
05 * * * * /home/vadmin/development/test.sh
But nothing happened. I'm sure I did many things wrong. Where do I start to fix all of this?
# 2  
Old 12-22-2010
What makes you think it did not work? Not getting a mail?
That part is not correct, but you know cron logs its activity, did you look at the cron logs?

---------- Post updated at 17:52 ---------- Previous update was at 17:48 ----------

Why dont you try something like:
Code:
# log kernel diagnostic messages every 10 minutes
05,15,25,35,45,55 * * * * /usr/sbin/dmesg - >>/var/adm/messages 2>&1

# 3  
Old 12-22-2010
Thanks, for the response. I didn't think it ran because there was no output, and no e-mail. Where/how do I access the logs?

What does your suggestion do? I tried it, but I couldn't find any output for that.
# 4  
Old 12-22-2010
Tell us what OS you are using. For Linux, it's probably /var/log/cron for the logs. A script like:
#! /bin/bash
date >> /tmp/crontest.out
is what I would use to test cron. It appends a line to a file each time it runs. Your post implies that you just dropped some cron commands into some random file. You need to use the right file. Look at the man page for the crontab command. The crontab command changes the right file and also notifies the cron program to reread the file.
# 5  
Old 12-22-2010
Sweet. Ok, I can confirm that it is working. I am on Linux and used /var/log/syslog.

Thanks for the help!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Cronjob

How to set cronjob for 48 hours. I can set for 2 days as shown below. * * */2 * * It is creating confusion for 30 days & 31 days per month. (3 Replies)
Discussion started by: Nishit
3 Replies

2. UNIX for Dummies Questions & Answers

cronjob

Is the cronjob below can run only first wednesday of every month? 30 5 1-7 * 3 command please tell me (3 Replies)
Discussion started by: Anjan1
3 Replies

3. UNIX for Dummies Questions & Answers

Cronjob help

Hi I am very new to linux. I want to run a cronjob every 15 minutes that checks a directory for files. If the directory contains more than ten files I want it to send an email to me. All I have is this... */15 * * * * ls -l | wc -l | | mail -s "This is just a test" I would... (2 Replies)
Discussion started by: LinuxNewb
2 Replies

4. UNIX for Dummies Questions & Answers

how to cancel a cronjob if the cronjob still running

hi everyone I'm newbie in this forum hope I can get some help here :) I have a command in crontab that executed every 1 minute sometime this command need more than 1 minute to finish the problem is, the crontab execute this command although it's not finish processing yet and causing the system... (7 Replies)
Discussion started by: 2j4h
7 Replies

5. AIX

cronjob

Hi, I want to schedule a script on daily basis in morning 8:00 A.M and 5:00 P.M , how can i achieve this, i want the parameter 0 ? * * * what will be the second parameter in my case. Regards (1 Reply)
Discussion started by: maooah
1 Replies

6. Shell Programming and Scripting

Cronjob

Hi, I'm totally new to shell scripting. I need help in my crontab script. I'm trying to read some values from user (username, log file directory, server) and then use those value to create a crontab for log rotation after some interval of time. creating crontabs manually isn't big deal.... (11 Replies)
Discussion started by: MisterKhan
11 Replies

7. Solaris

at vs cronjob

HI, What is the differnece between at / con job? thanks in advance. (1 Reply)
Discussion started by: mokkan
1 Replies

8. UNIX for Dummies Questions & Answers

cronjob

hi iam new at unix.iam running a cronjob,which i want to run on the first day of every month at 1AM.this is what i have specified: 00 01 1 * * is this corect? (1 Reply)
Discussion started by: wiz83
1 Replies

9. HP-UX

CronJob

Dear Guru, I have submitted some cronjobs that has been running for quite sometimes. However, today I counter some cronjob did not run. Can you please explain what causes this to happen. Any system setting that limit number of cronjob per minutes to be started, etc? Thanks. Kelly (1 Reply)
Discussion started by: hcng08
1 Replies

10. Shell Programming and Scripting

Cronjob

Please can someone help me. I need to set up a cron job to measure CPU usage, Disk I/O and memory usage over a period of 1 minute along with the number of users logged into the system. I also need to send it to another user besides myself every hour. Please can someone help me! Thanks. (4 Replies)
Discussion started by: gerwhelan
4 Replies
Login or Register to Ask a Question