Server :: Script Works When Run But Not When Called By Cron
Aug 28, 2010
I've made a bash script to do scp a file from another server and tested it successfully by executing it manually. However, when I scheduled it by cron, I received a mail from root saying permission denied.
The script is at:
It's supposed to secure copy a file from a remote host to:
The script's content is (No need to supply password as I've done the ssh-keygen thing):
Code:
From what I can make out of the mail, it appears that it has problem saving it to the /home/backup directory.
Script programming question for the experts. I have written a bash script that works fine if I execute from the shell interactively. However, once I schedule it to be executed via cron, it just wouldn't work. I believe this has to do with cron running in a different environment than the one I am in when I putty in.
The bash shell script does refer to environment variables in the .cshrc file. I guess these aren't available to the cron? How can I load them into the script if I want them to be available to the cron locally within the script?
I have a script that pops up a jpg file several times a day as a reminder. The script is called up by crontab and it works perfectly.The issue is that I want the script to also perform a system "beep" in addition to popping up the jpg file. When I test it on the command line everything works but when I run it in cron the jpg file pops up but the beep doesn't beep. I'm thinking the problem is in the "echo -e \a" part. I must be missing something.Here is my script:
I'm really running into a wall trying to figure this out. I have a Bash script and narrowed down the one command that doesn't seem to work via cron and it's my pgp decrypting line. Works fine if I run the command via terminal but if I run it via cron it doesn't output anything.crontab -e shows the cronjob and it runs, creates the log file with no output. Is there maybe something I need to run as well? Permissions look set, unless the cron is running as a different user(was under the assumption if it showed up under crontab while logged into that user, then it would run as that user.
I feel there's a bit of a misunderstanding going on between C++ and me...My problem is that I have a deque of pointers to a class, and create objects then add them to the deque in a for loop. However, the destructor is called on the object as soon as the loop quits.
Code:
This prints:
Code:
Now, if I change the deque from deque<Test*> to deque<Test> then it works fine - I get:
Code:
However, I can't do this with my actual code, because I am creating a deque of pointers to an abstract class, so it won't let me instantiate the class. (This is all so that I can take advantage of polymorphism, and call functions on a set of similar objects without worrying what type of object I'm dealing with).
So, I suppose my question is: what is the correct way to create that deque of pointers to the abstract class? I don't seem to be barking up the right tree currently.
Exactly what sequence of files are called as in the .my_profile,.profile,.vimrc,.vim. These are few files that I are there on the server. I want to know which file is called first and what sequence. Also can you point me to some links that tell exactly what are these files for.
I always use professional services to secure my servers. Everything was fine for years but a week ago my server got hacked.I don't know how the hacker got my username/password - it was not something like admin, password.9 months ago my PC was infected with some virus which connected to the FTP server by using password which was saved in CuteFTP and infected all index files with some javascript. Then I changed the user/FTP password and didn't save it anymore in Cute FTP. Of course, I checked all the folders and re-uploaded all infected files. Is it possible that this virus uploaded some hidden file which was able to get the new password for this account?
The server was hacked from so called Tor IP address. I am tiref of worrying about server security and now have an idea to get a static IP address from my ISP and to allow logins only from this IP address. What do you think about it? This idea looks good for me but are there any risks to lose access to the server. Can ISP provider change the static IP address for some reason?
I have an HP proliant ML 350 G4P. I am looking to download same sort of software that dell has called open manage for my HP. I have now idea what HP calls it. I went to the hp site to look up that server and there are a bunch of utilities but its not clear which one i need. I am running CentOS 5.
I have added some executable scripts to /etc/cron.daily but don't get the stdout/stderr output from them as mail (or anywhere else I have found). At least one of them is running (because I can see that it has added a file to the disk).
The peculiar thing is that I do get the output from /etc/cron.daily/0logwatch (part of the logwatch package) as an email each day.
The MAILTO line in /etc/crontab is "MAILTO=root" (unchanged from default). Same for /etc/anacrontab.
I do have an alias at the end of /etc/aliases which redirects root's mail to my own account, but this alias works fine for mail I send manually. (It also appears to work fine for the output from the file /etc/cron.daily/0logwatch.)
I put in my cron entries to run my backup script which rsyncs my data to my 2nd drive, however on a hunch I checked my backup drive which mounts automatically via fstab and I realize it had not ran in a while. I checked cron and there were no entries for it. I got to wondering if I should ever be worried about a cron update coming down and over-writing my existing cron file with the backup entries in it to run.
I want to make a cron job for my webserver, only it seems not to work...
I have now the followig to test (every 16th minute of the hour, write test to a file), but it doesn't show up. When I write out the cron, it is done to the file: /tmp/crontab.QXsBIO/crontab . How to make cron work? It must be very easy, but I have real troubles getting it fired up.
My Linux version is debian lenny and the cron file looks like (crontab -e):
I have a cron job to run every 15 minutes. The cron job is running per /var/log/cron. It lists the job every 15 minutes.
[Code]...
I do not see any errors. I also looked in /var/log/messages for any errors and it does not list any. I added a line to the script that is running to send an email to me to see if it is running or not. When I run the script from the command line, the script runs without error and I get an email. I have searched and can not find what it going on. Is there some where else errors might be? Could there be a permission issue? The cron job is not being added by the root user.
I have a crontab related question which I am hoping someone can answer. I recently took over a Redhat Enterprise 5 Server, and I was told by the previous Server Admin that there is a cron job that does the backups. I ran the following command to get a list of all users:
Code: cat /etc/passwd | grep "/home" |cut -d: -f1
I then ran the following command for each of those users to see if they have any crontabs associated with them:
Code: crontab -u USER -l
It doesn't show any crontab entries for any users (including root). But I am positive that there is a scheduled job somewhere because the backups are still running every night.
My question is how do I get a cron job to pick up the user's ~/.my.cnf? If the user runs the shell script, everything is fine. The cron entry has the same user run the job, and I've tried #!/bin/bash -l in the shell script with no success.
Here are the details:
I have a bash shell script that launches a Python program. The python program issues an external shell mysql -e command.
I don't want the python code to use use -u user-name -pMyPassword, db-name, because this is contained in ~/.my.cnf. The python code doesn't have to use these parameters if run interactively, but does have to if run from cron.
I have a simple cron job that runs every night & I tested this manually by just running the command as root in bash and all worked fine. It took some time but the crob job finished and I got my results emailed to me perfect / as expected.
Here is root's cron job listing:
Code:
Now I noticed that I never ever got anything emailed to me the following day so I am wondering if perhaps the Cron daemon doesn't have permissions or has an issue running / executing the command rather than when I test the command as 'root'? When I view my logs, I can see the command being executed and don't see any errors however I don't get email results when Cron runs the job rather than me taking the command and running it manually in Bash...then it works. What am I missing?
I'm trying to set-up a cron job that uses rsync to transfer back files from a remote server. ssh on the remote server is running on port 12345 but this seems to be a problem. My script looks like this:
I have an issue, it doesn't happen every day, I can't seem to trace it down. It happens at 4:02am the cron.daily kicks of at 4AM.. The following is from the /var/log/messages. I receive an panic error then the server shuts down.
I am using cent os 5. I My server daily shutdown at 7:00 PM.I want to see the log file of my cron activity what the process is successfully started or not
Here are the specs of my machine: Linux matrix 2.6.18-92.el5 #1 SMP Tue Apr 29 13:16:12 EDT 2008 i686 i686 i386 GNU/Linux Red Hat Enterprise Linux Server release 5.2 (Tikanga)
When I run an ldapsearch in root, it works fine. tcpdump filtered by dest IP shows packets captured.
When I run an ldapsearch in a perl script as root, it works fine. tcpdump filtered by dest IP shows packets captured.
However, when I run it via a perl script in my cgi-bin directory it fails. tcpdump shows no packets captured. When I added a "2>&1" to my ldap search in my cgi script, I got "ldap_bind: Can't contact LDAP server (-1)".
I ran a "whoami" in my cgi script and it showed up as apache.
Another twist to all this is that I ran the same test on my slackware box, and everything works (esp the cgi script). Here's what the specs are on that machine:
Linux slackvm 2.6.29.6-smp #2 SMP Mon Aug 17 00:52:54 CDT 2009 i686 Intel(R) Core(TM)2 Duo CPU P8400 @ 2.26GHz GenuineIntel GNU/Linux
I checked the permissions on the ldapsearch file and directory, and they're the same (755).
Could there be something blocking the apache user on my Red Hat box from sending packets out?
I have a file server that is an NIS client. User home directories are auto-mounted from another server. Users are not able to run cron jobs. The /var/log/cron logs says: Jan 6 14:33:01 inclination crond[3217]: (username) ORPHAN (no passwd entry)
I tried adding an entry in /etc/passwd, /etc/group, and /etc/shadow but the test script I have still doesn't seem to run although cron thinks it did. The log entry for these attempts looks like: Jan 6 15:30:01 inclination crond[4312]: (username) CMD (/home/username/test-script)
Now root does seem to be able to run cron jobs with no problem. My test script works fine from cron when runs as root. I suspect there's an issue with how I have NIS configured but I can't find any info. The test script runs fine from the command line when logged in as myself.