Run crontab every 6 days


 
Thread Tools Search this Thread
Operating Systems HP-UX Run crontab every 6 days
# 1  
Old 08-25-2008
Run crontab every 6 days

Hi all,
I need to run a shell script every 6 days using crontab. I've been searching a bit and found the following syntax for this:

Code:
* * */6 * * /apps/temp/maxx.sh > /apps/temp/maxx.log 2>&1

respectively
Code:
* * 0/6 * * /apps/temp/maxx.sh > /apps/temp/maxx.log 2>&

Unfortunately when trying to save the crontab -e file I'm getting the error message:

Code:
* * */6 * * /apps/temp/maxx.sh > /apps/temp/maxx.log 2>&1

crontab: error on previous line; unexpected character found in line.


Im on HP-UX frasdoc1 B.11.00 U

Any ideas will be highly appreciated
# 2  
Old 08-25-2008
I dont believe this syntax to work in HPUX (I wonder on what it does though...)
but you can also let a script to run every day using cron, and in this script, test if ist a 6th day and if so run your job...
# 3  
Old 08-25-2008
Tools What about run daily, but then check for the day?

1) Set the crontab to call your script everyday.
2) Your script would then read a file to learn the current count. If count is appropriate, execute your stuff and set count back to 0; else increment count by 1 (or increment by 1 immediately / adjusting test number accordingly). Lastly, write the count variable to the file again.

The following is just off the top of my head, but perhaps gives you the idea...

Code:
count=$(cat my_counter_file)
count=$((count+1))
if [ $count -ge 6 ]
   then
      do stuff here / call another script
      count=0
fi

echo $count >my_counter_file

# 4  
Old 08-25-2008
or do something like this on the crontab line when running as joeyg suggests - every day:
Code:
[ $((  ($(date +%s)/86400) % 6  )) -eq 0 ] && apps/temp/maxx.sh > /apps/temp/maxx.log 2>&1

# 5  
Old 08-28-2008
the format in crontab is:
Code:
00 23 * * 5 /apps/temp/maxx.sh > /apps/temp/maxx.log 2>&

1

so on day six of the week you get your job at evening at 11.

first zeros means, minute, then hour, then monthday if specified, then every month if * and then day five at the week, zero is sunday.
you can read all of this by man crontab.

regards
# 6  
Old 08-28-2008
The */6 syntax exists in Vixie cron, which is the standard Cron on Linux (and BSD?) but not in many legacy/"enterprise" systems.

Another option is a self-scheduling at job.

Code:
#!/bin/sh
: your code here
echo "$0" "$@" | at now + 6 days

# 7  
Old 08-28-2008
Great solution here!
brilliant era!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can't get my crontab to run

I'm trying to get a crontab to run, every Friday at 11am and the problem is that it isn't running at all. 0 11 * * 6 /Users/martinb/Documents/SYSADMIN/Regular-Scripts/Info-And-Backups.sh Here's a link to a screenshot of my script (I've censored my email address). Screen Shot 2017 11 03... (3 Replies)
Discussion started by: $shell_Learner
3 Replies

2. Shell Programming and Scripting

Crontab scheduler to execute script every 45 days

Can someone please help me on how to schedule script to run every 45 days in crontab ? Thanks, Prince (5 Replies)
Discussion started by: prince1987
5 Replies

3. Shell Programming and Scripting

Script fails to run properly when run from CRONTAB

Hello all, I'm trying to write a script to gather and send data and it works just fine at the bash command line, but when executing from CRON, it does not run properly. My scripting skills are pretty limited and there's probably a better way, but as I said it works at the command line, but... (12 Replies)
Discussion started by: rusman
12 Replies

4. Shell Programming and Scripting

Different output when run from crontab

Hi, I have a script which checks to see if an app is running and will restart it if it is not. For some reason when I run it from the crontab it always says it is not running. The script is as follows: - #!/bin/sh # # The following script will look for the PID of SickBeard and output... (15 Replies)
Discussion started by: simpic
15 Replies

5. Shell Programming and Scripting

run commands within a script on certain days

Hi, please advise a script, something like this: If ; then do something else ( or for any other day of the week ) do otherthing fi Thanks (5 Replies)
Discussion started by: fed.linuxgossip
5 Replies

6. Shell Programming and Scripting

Scheduling a command to run every 3 days through cron

Hello, I have to schedule a command to run on every 3 days. Whether the below cron entry will work? 0 3 */3 * * command Please help me out and thanks in advance! (6 Replies)
Discussion started by: Arunprasad
6 Replies

7. Solaris

crontab to run every 20 second

Hi experts, I want to set the crontab for my script which will run every 20 seconds I think below could be the possible one- */3 * * * * /export/home/username/scripts/runing.sh As my system(SOLARIS 9) is live- i am confused to implement before make sure !!! I need... (4 Replies)
Discussion started by: thepurple
4 Replies

8. UNIX for Advanced & Expert Users

CRONTAB does not run since reboot

Hi, we reboot our Linux server yesterday and since then (specialy last night) no job from crontab has run. Any idea ? What should I look for to investigate? Many thanks. (5 Replies)
Discussion started by: big123456
5 Replies

9. UNIX for Advanced & Expert Users

crontab couldn't run through, help

I have created two scripts to call SQL scripts to do some work. The scripts was successfully executed many times by manual. When I scheduled two scripts in crontab, I gave all necessary parameters. It could start, but couldn't run through. The log file didn't give enough error info. Anyone can help... (10 Replies)
Discussion started by: duke0001
10 Replies

10. Shell Programming and Scripting

output from crontab run

Hi, I am trying to schedule a job in linux through the crontab command.My script actually does some text processing and echoes some output.My cron scheduler is working fine,but the output messages(echoes from script) is mailed to my mail account(in unix -/var/local/mail).Is it not possible... (0 Replies)
Discussion started by: DILEEP410
0 Replies
Login or Register to Ask a Question