LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-19-2011, 12:57 AM   #1
ramesh14
Member
 
Registered: Apr 2008
Location: Hyderabad
Distribution: RHEL5,Fedora 8/9
Posts: 119
Blog Entries: 1

Rep: Reputation: 15
Question cron job error in for root user


hi
i am using fc9 i wrote small script
vi /script/script.sh
#/bin/bash
cp /test/test.txt /log_backup/
rm /test/test.txt

i wrote cron job in root user
crontab -e
11 11 * * * /script/script.sh

/etc/init.d/crond restart

tail -f /var/log/cron
Apr 19 11:11:01 localhost CROND[24882]: (root) CMD (/script/script.sh)

but the tes.txt file is didn't copied the /log_backup
/test/test.txt file also didn't removed
i didn't understand the script was execute properly but i didn't get the test.txt file and not removed test.txt file
pls any one guide me what in wrong
thanks in advance

Last edited by ramesh14; 04-19-2011 at 01:02 AM.
 
Old 04-19-2011, 01:27 AM   #2
hujer
LQ Newbie
 
Registered: Jun 2009
Posts: 3

Rep: Reputation: 1
missing ! in first line, probably.
and check execution permission.

Quote:
Originally Posted by ramesh14 View Post
hi
i am using fc9 i wrote small script
vi /script/script.sh
#/bin/bash
cp /test/test.txt /log_backup/
rm /test/test.txt

i wrote cron job in root user
crontab -e
11 11 * * * /script/script.sh

/etc/init.d/crond restart

tail -f /var/log/cron
Apr 19 11:11:01 localhost CROND[24882]: (root) CMD (/script/script.sh)

but the tes.txt file is didn't copied the /log_backup
/test/test.txt file also didn't removed
i didn't understand the script was execute properly but i didn't get the test.txt file and not removed test.txt file
pls any one guide me what in wrong
thanks in advance
 
1 members found this post helpful.
Old 04-19-2011, 01:33 AM   #3
ramesh14
Member
 
Registered: Apr 2008
Location: Hyderabad
Distribution: RHEL5,Fedora 8/9
Posts: 119

Original Poster
Blog Entries: 1

Rep: Reputation: 15
hi hujer

i edited
#!/bin/sh
cp /test/test.txt /log_backup/
rm /test/test.txt

but i didn't get the out put of the script
pls guide me
thanks in advance

Last edited by ramesh14; 04-19-2011 at 06:26 AM.
 
Old 04-19-2011, 04:30 AM   #4
ramesh14
Member
 
Registered: Apr 2008
Location: Hyderabad
Distribution: RHEL5,Fedora 8/9
Posts: 119

Original Poster
Blog Entries: 1

Rep: Reputation: 15
hi
my need is my securey admin is audit users activity on the server he asked /var/log/audit.log,secure. and user .bash_history
files in .tar.gz.gpg formate with password i wrote the script below like this
vi /root/gpgpass
passworkd

vi /scripts/log_dsa1.sh
#!/bin/bash
mkdir /var/log/user_audit_`date +%F`
cp /var/log/secure /var/log/user_audit_`date +%F`/secure_`date +%F`
cp /var/log/audit/audit.log /var/log/user_audit_`date +%F`/audit_`date +%F`.log
cat /home/user1/.bash_history >> /var/log/user_audit_`date +%F`/user1_`date +%F`
cat /home/user2/.bash_history >> /var/log/user_audit_`date +%F`/user2_`date +%F`
cat /home/user3/.bash_history >> /var/log/user_audit_`date +%F`/user3_`date +%F`
tar -cvzf log_dsa1_`date +%F`.tar.gz /var/log/user_audit_`date +%F`
gpg --passphrase-file /root/gpgpass -c log_dsa2_`date +%F`.tar.gz
rm -rf log_dsa1_`date +%F`.tar.gz
rm -rf /var/log/user_audit_`date +%F`


this script i ran manually on the server its working fine

i assigned the crone job for root user

crontab -e

15 6 * * * /scripts/log_dsa1.sh
corntab -l

15 6 * * * /scripts/log_dsa1.sh
tail -f /var/log/cron
Apr 19 6:15:01 server crond[14188]: (root) CMD (/root/log_dsa1.sh)


but i dint get the .tar.gz.gpg file in /log_backup/

if i remove the (gpg --passphrase-file /root/gpgpass -c user_audit_`date +%f`.tar.gz) in the scrpt file it's working fine but i need gpgp encriptin pls guide me how to encript the user_audit`date +%F`.tar.gz file with password on my cron job

thanks in addvance........

Last edited by ramesh14; 04-19-2011 at 06:42 AM.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to make root cron job to send email if there is output mirror51 Linux - Newbie 3 08-12-2009 01:01 AM
cron job as a non-privileged user do not run chakkerz Linux - General 5 06-03-2008 08:28 PM
Fedora 8 selinux blocks root cron but not user cron Infinity Fedora 7 11-29-2007 08:21 AM
Command not working in cron job, but works fine in root Roosta21 Linux - Software 4 11-22-2007 08:08 AM
running cron job as an ordinary user fahad26 Linux - General 1 06-30-2005 03:46 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 12:55 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