LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-04-2023, 02:19 PM   #1
frrobert
Member
 
Registered: Mar 2008
Location: South Bend, IN
Distribution: Ubuntu 18.04 & 20.04
Posts: 37

Rep: Reputation: 1
AT Job question


I have a script that creates a series of at jobs for the day.

If I run the script from the command line the at jobs are created. The at jobs run at the specified time and they do what they are supposed to do.

If I run the script the as a cron job the at are created. The at jobs appear to run at the specified time but they do not do anything.

The command that is run from at is

Code:
/home/frrobert/bin/issbeacon 3
The number at the end is a variable in minutes that says how long to run the script. The number varies for each job and is set by the initial script.

Whether I run the script from the command line or as a cronjob:

When I run atq the all the jobs show up and if I run at -c jobnumber the command shows as above with both full path and the variable.

Everything is run as user.

The initial script can be found here

https://github.com/frrobert2/AWK-scr...ssdailycronjob

So I am confused by what appears to be identical at jobs the ones that are created via cron do not run correctly.

Any ideas?

Thanks
 
Old 01-04-2023, 11:05 PM   #2
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 7.7 (?), Centos 8.1
Posts: 18,145

Rep: Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672Reputation: 2672
Looking at your code, I'd do at least 2 , maybe 3 things:

1 insert
Code:
set -xv
as a new line 2 ie immediately after #!/bin/bash


2 Set the cronjob to log stdout & stderr eg
Code:
/home/frrobert/bin/issbeacon 3 >/tmp/issbeacon.log 2>&1

3 Ensure ALL cmds & files have the fullpath specified; eg you haven't done that for 'mktemp' or 'date'.
Generally cron has a minimal env, inc cmd paths, so just assume it has none and code accordingly

HTH
 
1 members found this post helpful.
Old 01-05-2023, 11:33 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 23,913

Rep: Reputation: 5268Reputation: 5268Reputation: 5268Reputation: 5268Reputation: 5268Reputation: 5268Reputation: 5268Reputation: 5268Reputation: 5268Reputation: 5268Reputation: 5268
The default cron path does include /usr/bin which is where mktemp, date and at are located so the OP should be ok but I agree that using the full path is always better.

I simulated your script as much as possible but I don't know anything about issbeacon and created a dummy script that writes data to a file. I modified the time when the at jobs ran so I did not have to wait but I could successfully run the script from cron, the at jobs were created and the test data file showed the correct information.
 
1 members found this post helpful.
Old 01-05-2023, 03:48 PM   #4
frrobert
Member
 
Registered: Mar 2008
Location: South Bend, IN
Distribution: Ubuntu 18.04 & 20.04
Posts: 37

Original Poster
Rep: Reputation: 1
I have made the suggested changes. The cron job ran fine as always and created the at job. The at job runs at roughly 23:00 tonight. I will let you know if the at job runs correctly.

Thank you for the suggestions
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
I need back support , to my new job, this is my first job ... help me plz? praveencheruku AIX 3 03-30-2010 08:37 AM
linux cron job duplicate job question cpthk Linux - Newbie 4 09-11-2009 09:52 PM
lpr job number -- where does lpr get the job number? conetic Linux - Software 1 02-28-2008 04:38 PM
Can you start a job without getting the job number spit back out? BrianK Linux - General 5 12-13-2007 09:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:57 PM.

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