Visit Our UNIX and Linux User Community


Bash/cron issues


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Bash/cron issues
# 1  
Old 12-19-2012
Bash/cron issues

Hi all, I am trying to run a cronjob to push my files to my git repo once a week and output a prompt to a logfile, my script works fine if I invoke it manually but my cronjob wont run for some reason, I have sourced the file, and restarted my Mac to no avail, right now I believe I have the cronjob timed for every 5 min for testing but would like it to run once a week once I get it working. Any suggestions would be appreciated, thanks in advance.
Cronjob:
Code:
*/5 * * * *  /Users/gmenfan83/commit.sh >> /Users/gmenfan83/cron.log

---------- Post updated at 08:05 PM ---------- Previous update was at 08:02 PM ----------

as I am reading my own post I saw I had no
Code:
.

after
Code:
/commit

so would this invoke the script
Code:
/Users/gmenfan83/.commit.sh

?
# 2  
Old 12-19-2012
Can you source your .profile file and give it another try?
Code:
*/5 * * * *  . .profile; /Users/gmenfan83/commit.sh >> /Users/gmenfan83/cron.log

# 3  
Old 12-19-2012
Quote:
Originally Posted by bipinajith
Can you source your .profile file and give it another try?
Code:
*/5 * * * *  . .profile; /Users/gmenfan83/commit.sh >> /Users/gmenfan83/cron.log

I did to no avail, I do not get it, perhaps it is running but I am printing the message wrong in my script? If there is nothing to push it will not show on git and if my "success" message is wrong then it will show nothing in the log file

Here is the line for "success message" in my script($now = date/time)
Code:
echo "Cron/.emacs successful $now"

# 4  
Old 12-19-2012
BTW only some versions of cron allow to use */5. You can replace it with 5, also redirect stderr to another file:-
Code:
5 * * * *  . .profile; /Users/gmenfan83/commit.sh >> /Users/gmenfan83/cron.log 2>/Users/gmenfan83/error.log

# 5  
Old 12-19-2012
Quote:
Originally Posted by bipinajith
BTW only some versions of cron allow to use */5. You can replace it with 5, also redirect stderr to another file:-
Code:
5 * * * *  . .profile; /Users/gmenfan83/commit.sh >> /Users/gmenfan83/cron.log 2>/Users/gmenfan83/error.log

Thank you, hopefully this works

---------- Post updated at 08:55 PM ---------- Previous update was at 08:37 PM ----------

Still nothing, I am truly stumped! Like I said the script runs great once manually invoked, the error log is empty as well.
# 6  
Old 12-19-2012
Check if crond - daemon to execute scheduled command is running:-
Code:
ps -eaf | grep crond | grep -v grep

If yes, check the mailbox and verify if you got any message from cron with an error:-
Code:
mail

# 7  
Old 12-19-2012
No output for anything, not even the commands to check the daemon, I tried starting it as well with service crond start but that returns service not found, I would say that this may be due to Apple switching to launchd but I am still able to run the cron man page crontab -e etc., I wonder if they omitted the daemon but the leftovers are still in bash?

Previous Thread | Next Thread
Test Your Knowledge in Computers #994
Difficulty: Medium
A hypervisor or virtual machine monitor (VMM) is a computer software, firmware or hardware that creates and runs virtual machines.
True or False?

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Db2 command issues with cron

Hi, I have a very simple script that queries from a DB2 table. The script has 3 parts - (i) Sets the db2profile (ii) connects to db2 using credentials (iii) executes the query.This script works fine if i run it manually from the command prompt. However when scheduled in crontab, it proceeds... (2 Replies)
Discussion started by: VeePee
2 Replies

2. Shell Programming and Scripting

Bash Case Issues..

Hi, I'm having some trouble with using "case...esac" in Bash. I've googled it and am stuggling to understand the syntax and how to do certain things. Firstly, I want to be able to choose a case based on a variable number For example, I have in my code a place where a user can enter... (2 Replies)
Discussion started by: Ste_Moore01
2 Replies

3. UNIX for Advanced & Expert Users

Cron security issues?

Does the use of cron (HP-UX 11) present a security risk IF it is only given to accounts which have shell access anyway. If it does present a risk, what is the risk? Can a script (or command) run via cron; run anything, write anywhere or read anywhere that the same user can not do outside of... (2 Replies)
Discussion started by: eileenkeeney
2 Replies

4. Shell Programming and Scripting

Unix bash script (mv issues);

Hey guys, I've registered here as I need urgent help. This is assignment for school and as you can see below I've completed the work. I'm simply stuck on one area. :wall: This script takes the first parameter (which is to be the new extension) and each parameter after that is a file... (1 Reply)
Discussion started by: Cynosure
1 Replies

5. Shell Programming and Scripting

Bash: renaming file issues.

Hi, i want to rename a group of directories and files of my music, some items are like this: - , for directories. - , for files. I want to do something like this: , for directories. , for files. This is my code: #!/bin/bash for fname in *.mp3; do echo item: $fname mv... (2 Replies)
Discussion started by: josco1982
2 Replies

6. Shell Programming and Scripting

Bash Script issues

So what i am trying to do is write a script that takes in any number of scrambeled words and unscrambles them. I have already addressed the issues of partial matches, exits silently if there are no matches, and finds words regardless of case that they were input. but while trying to get it so... (3 Replies)
Discussion started by: alindner
3 Replies

7. Shell Programming and Scripting

Bash script issues

Hi. The below part of my bash script kicks out the following error message: $ ./extract_eod_report_stats_new.sh 2010-04-23 ./extract_eod_report_stats_new.sh: line 204: syntax error near unexpected token `(' ./extract_eod_report_stats_new.sh: line 204: `TRANSACTIONS_RECEIVED_TOP=`grep... (6 Replies)
Discussion started by: Peter.Lovell
6 Replies

8. Solaris

cron / crontab issues - solaris 10

I am having some issues with my cronjobs not running in solaris 10. Cron is running: ~> ps -ef | grep cron root 202 1 0 Jul 18 ? 0:01 /usr/sbin/cron bender 1646 1562 0 01:57:49 syscon 0:00 grep cron crontab -l lists the cronjob and I *think* its in the... (8 Replies)
Discussion started by: ippy98
8 Replies

9. UNIX for Dummies Questions & Answers

IP connection Bash script issues

Hello I need assistance with a bash script that needs to tell me whether in the last "x" days (which is a variable) anyone connected to the xxxx IP (which is another variable). Thank you! (1 Reply)
Discussion started by: Melchiah
1 Replies

10. Shell Programming and Scripting

FTP Cron issues

I am on AS3 Update 4 Linux and am having an issue with an automated ftp script, I tried using the fd/sub proc method and that did not seem to work either. I normally use the following method to perform my ftp's but for some reason it works if I launch the script at the command line but in Cron it... (4 Replies)
Discussion started by: bryanthomas
4 Replies

Featured Tech Videos