LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-12-2006, 03:25 AM   #1
simba_cubs
LQ Newbie
 
Registered: Jul 2006
Posts: 10

Rep: Reputation: 0
Cron job not quite working...


I have created a cron job which I need to run every Friday at 20:05.
I have edited the crontab file by using the crontab -e command and inserted the following text...

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=me@mydomain.com
HOME=/
#!/bin/bash
05 20 * * 5 root /usr/sbin/vmsnap_to_local > /var/log/vmsnap_to_local_`date +%F_%T`.log 2>&1

I've tried to break this down as to where it's not working and if I run the "/usr/sbin/vmsnap_to_local" command it runs the script.

If I create the output file manually "/var/log/vmsnap_to_local_`date +%F_%T`.log" that works.

But it doesn't seem to work on the schedule. Can anyone give me a clue

Many thanks in advance for your help
 
Old 10-12-2006, 04:00 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you're editing your personal crontab but using the formatting of the system wide /etc/crontab file. even root has their own priviate crontab and these do not contain the user column after the time logic to define who the command is run as. basically remove the word "root" and i expect it will work ok, as that column is not expected there, so it trying to run "root" as the actual program.
 
Old 10-12-2006, 05:23 AM   #3
simba_cubs
LQ Newbie
 
Registered: Jul 2006
Posts: 10

Original Poster
Rep: Reputation: 0
ok thanks I'll give it a go.

If that is my personal crontab, where would I place that scheduled job - in the cron.weekly schedule, if it's a system wide job that needs to run every week?

Thanks again
 
Old 10-12-2006, 05:25 AM   #4
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
Quote:
Originally Posted by simba_cubs
ok thanks I'll give it a go.

If that is my personal crontab, where would I place that scheduled job - in the cron.weekly schedule, if it's a system wide job that needs to run every week?

Thanks again
Either that way or just place it directly in root's crontab.
 
Old 10-12-2006, 05:41 AM   #5
simba_cubs
LQ Newbie
 
Registered: Jul 2006
Posts: 10

Original Poster
Rep: Reputation: 0
I'll give that a go - many thanks for your help and prompt reply.
 
Old 10-16-2006, 03:55 AM   #6
simba_cubs
LQ Newbie
 
Registered: Jul 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Hi me again

I checked to make sure the schedule task ran, but unfortuantely it didn't
This is the syntax within the crontab of root.

05 07 * * sat /usr/sbin/vmsnap_to_william >/var/log/vmsnap_to_william_`date +%F_%T`.log 2>&1

For the time being I have run the script manually and it's chugging away, but I really need to get this working via the crontab please...

Thanks
 
Old 10-16-2006, 04:21 AM   #7
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
what exactly is failing? What do you get when you remove the re-direct
at the end, anything in the mail?


Cheers,
Tink
 
Old 10-16-2006, 10:19 AM   #8
simba_cubs
LQ Newbie
 
Registered: Jul 2006
Posts: 10

Original Poster
Rep: Reputation: 0
To be honest I haven't tried, so I need to run it as....

05 07 * * sat /usr/sbin/vmsnap_to_william

That correct?

Sorry to be vague I'm a newbie to Linux

Thanks
 
Old 10-16-2006, 12:26 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Yeah. That should give you whatever the script produces in crons output.


Cheers,
Tink
 
Old 10-16-2006, 12:57 PM   #10
ygloo
Member
 
Registered: Aug 2006
Distribution: slack
Posts: 323

Rep: Reputation: 30
....................................

Last edited by ygloo; 10-16-2006 at 12:59 PM.
 
Old 11-08-2006, 06:27 AM   #11
simba_cubs
LQ Newbie
 
Registered: Jul 2006
Posts: 10

Original Poster
Rep: Reputation: 0
Hi tried editing the crontab using crontab -e.

My crontab looks like this...

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=me@mycompany
HOME=/
#!/bin/bash
20 14 * * mon root /usr/sbin/vmsnap_to_local

I've also tried this...

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=me@mycompany
HOME=/
#!/bin/bash
20 14 * * mon /usr/sbin/vmsnap_to_local

When I exceute the "file" command against vmsnap_to_local, it returns the following...

vmsnap_to_local: Bourne-Again shell script text executable

Would that make any difference?

Thanks in advance for your help.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
simple cron job: not working Robert0380 Linux - Software 3 06-24-2008 04:45 AM
cron job suddenly stopped working Gisli Linux - Software 1 08-25-2005 12:03 PM
GPG cron job not working michredhat Linux - Software 1 12-07-2004 10:27 PM
cron job working2hard Programming 6 07-28-2004 09:12 PM
Cron job T-Rex Linux - Newbie 1 09-26-2001 11:28 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration