Welcome to Tech Support Forum home to more then 136,000 problems solved. Issues have included: Spyware, Malware, Virus Issues, Windows, Microsoft, Linux, Networking, Security, Hardware, and Gaming Getting your problem solved is as easy as:
1. Registering for a free account
2. Asking your question
3. Receiving an answer

Registered members:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* See fewer ads.
* And much more..

 



Want to know how to post a question? click here Having problems with spyware and pop-ups? First Steps
Go Back   Tech Support Forum > Alternative Computing > Linux Support
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Linux Support Linux - Operating Systems and Applications Support

Reply
 
LinkBack Thread Tools
Old 10-21-2008, 01:12 PM   #1 (permalink)
Registered User
 
Join Date: Oct 2008
Posts: 1
OS: Linux


running scripts under cron

I'm having an issue with a couple of scripts under cron. I did not write these scripts, but they do work when manually ran. They basically are used to decrypt pgp files we receive daily and then move the decrypted files to another location.

This is the first script:

cd /home/xxxxxx
ls -A1 *.pgp | sed 's/^/\/opt\/bin\/test2.sh /' >> /opt/bin/sed.txt
chmod 777 /opt/bin/sed.txt
/opt/bin/sed.txt
rm /opt/bin/sed.txt
mv /home/xxxxxx/*.pgp /home/xxxxx/archive
chown xxxxx /home/pcard/*.cdf
chgrp ftp /home/xxxxx/*.cdf
date >> /opt/bin/date.sed

This is the second script that runs within the first:

/usr/bin/gpg --passphrase-fd 0 --yes -o /home/xxxxx/`echo $1 | sed 's/.pgp//g'` /home/xxxxx/`echo $1` << EOF
xxxxxxx
EOF

So I am looking for any suggestions that may help me get these running under cron once again.

Last edited by AegidiusAK; 10-21-2008 at 01:14 PM.
AegidiusAK is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Important Information
Join the #1 Tech Support Forum Today - It's Totally Free!

TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free.

Join TechSupportforum.com Today - Click Here

Old 10-21-2008, 06:01 PM   #2 (permalink)
Registered User
 
Join Date: Oct 2007
Location: Littleton, Colorado USA
Posts: 470
OS: xp 64 sp2 Fedora Core 8 (vmware xp core 8 x32) Minix


Re: running scripts under cron

First. Do they still run. If you run the second script will it, without error run the first script? Your post says it will. Does it run without asking for any input, like a passphrase? So if the second scripts name is "second.sh", does it successfully run if you type in "/usr/local/bin/second.sh". My example will email the output results to you.

(I would add a line to each script as the first line "#!/bin/bash". That way the script executing subsystem will invoke the bash shell. If you want the "sh shell" then make the first line "#!/bin/sh". Drop the quotes around #!/bin/sh.)

0 */3 * * * (cd /opt/xxxx; /xxx/yyy/second.sh -q 2>&1 | mail -s "cron backup output" your-user-name)

You will have to do a "man 5 crontab" to get the meaning of the asterisk fields. In this example the program will be run every 3 hours. The granularity of a job being kicked off is every minute.

This example runs every minute:
* * * * * /usr/local/bin/keepalive.sh 2>&1 /dev/null

It runs a keep alive script that attempts to keep my comcast.net link up.

You need to edit your crontab or become "root" to edit a privileged cron. Just run "crontab -e". Reassign the environment variable EDITOR to your favorite editor, otherwise it defaults to "vi". Cron can run under any user including root. You will have to su to the user you want to install the cron for. Also for debugging, set the time interval for every minute, all asterisks, so the errors can be traced. My systems also write cron output to /var/log/cron, though errors are not written to this file, only errors from the cron program itself.
lensman3 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 04:54 PM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85