Cron job doesn't run (Perl & Centos) - perl

In my /etc/crontab file I write:
* * * * * PLACK_ENV=development -I /home/adrian/app/lib/ /home/adrian/app/script/db/log_to_db.pl
To make a cron job run every minute. The job is running the log_to_db.pl perl script, which inserts data to my database.
When I run in my terminal
PLACK_ENV=development -I /home/adrian/app/lib/ /home/adrian/app/script/db/log_to_db.pl
It's OK! The script runs.
But the cron job isn't working!
What can be wrong?
PD: My script starts like
#!/usr/bin perl
....
My cron log prints:
Jul 8 20:29:01 dev0001 crond[1829]: (*system*) RELOAD (/etc/crontab)
Jul 8 20:29:01 dev0001 crond[1829]: (CRON) bad username (/etc/crontab)
Jul 8 20:30:01 dev0001 crond[1829]: (*system*) RELOAD (/etc/crontab)
Jul 8 20:30:01 dev0001 crond[1829]: (CRON) bad username (/etc/crontab)
Jul 8 20:30:01 dev0001 CROND[13504]: (root) CMD (/usr/lib64/sa/sa1 -S DISK 1 1)

You need a username when putting it in the system crontab
* * * * * adrian PLACK_ENV=development -I /home/adrian/app/lib/ /home/adrian/app/script/db/log_to_db.pl
But as #jithin said, putting this in your user crontab (crontab -e) might make more sense.

Don't edit the crontab file directly. Instead use crontab -e and add the cron entry.
With reference to the link

Related

Can all command line utlities be scheduled?

I am using Hyperion Planning. There are a lot of in-built command line utilities. may I know if all these command line utilities can be scheduled to run using the windows task scheduler?
You can run all command using batch file. Just call batch file from task scheduler.
On Linux we schedule things as follows:
[apphyp#ichypp0013 ~]$ crontab -l
### Minutes hours DayOfMonth Month Weekday(0-6 Sunday-Saturday)
###
###
### DAILY ONLINE BACKUP Plan0
00 20 * * 1-5 /app/ncia/scripts/stop.hyp.sh 2>&1
30 20 * * 1-5 /app/ncia/scripts/backup_Planning0.sh 2>&1
00 22 * * 1-5 /app/ncia/scripts/start.hyp.sh 2>&1
### Automatic Transfer
00 09 * * 1-5 /app/ncia/scripts/automatic.transfer.FMC_to_R2C.sh >> /app/ncia/log/automatic.transfer.FMC_to_R2C.log
00 23 * * 0-4 /app/ncia/scripts/automatic.transfer.HRC_to_HR2C.sh >> /app/ncia/log/automatic.transfer.HRC_to_HR2C.log
30 22 * * 0-4 /app/ncia/scripts/automatic.launch.business.rule.FMC_Admin_PrepareAllData_to_R2C.sh >> /app/ncia/log/automatic.launch.business.rule.FMC_Admin_PrepareAllData_to_R2C.log

crontab executing hour apart , both set to BST: 2 servers. Why?

I've just moved servers and have overlap on crontabs running.
Both servers set to BST, but one sends me a log at
08:00 BST the other old one 09:00 BST
The crontab entry for both is
0 9 * * * /root/phpmaillog.sh > /dev/null 2>&1
Mystery?

In Solaris server with Putty, unable to delete copied file with some irregular special character

I use putty to log in to a solaris server. while i was performing a copy operation I pressed left arrow key to edit the file name but it kept adding this character ^[[D desperate I pressed return key and the copy operation got complete
cp temp.jar temp.jar^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D
I was planning to rename is as temp.jar.test, I used 'ls' command to check what has happened and to my surprise two files came up with same name!
root[dev1]# ls -lt temp*
-rw-r--r-- 1 root other 488554 Apr 11 02:25 temp.jar
-rw-r--r-- 1 root other 488554 Apr 11 02:22 temp.jar
-rw-r--r-- 1 root other 488554 Apr 11 02:22 temp.jar.041114
-rw-r--r-- 1 root other 488487 Sep 30 2013 temp.jar.032514
and I used 'rm' command to delete, the original file got deleted but the file copied with ^[[D character is not getting deleted. And I'm getting a msg like 'eisvr.jar.: No such file or directory'
Help me delete the file. I tried issuing 'rm temp.jar^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D'. It resulted in more errors.
The simplest way would be to run this command:
rm -i temp.jar?????????*
and answer yes when prompted to remove the bogus one.

JMeter Command Line Output

I'm running a JMeter test plan from command line and it's currently outputting something along the lines of:
Created the tree successfully using C:\*****\TestPlan.jmx
Starting the test # Thu Oct 11 10:20:43 EDT 2012 (1349965243947)
Waiting for possible shutdown message on port 4445
Tidying up ... # Thu Oct 11 10:20:46 EDT 2012 (1349965246384)
... end of run
Is there any way to turn off this output and have the plan execute 'silently'?
Found a way to do this, by following this article http://www.robvanderwoude.com/battech_redirection.php
and appending > NUL to the command
jmeter -n -t C:\***\TestPlan.jmx -Jhostname=%1 > NUL

Can't get launchd to work at Startup/Shutdown on OS X Lion

I followed some online guides trying to get some headless VMs to start/suspend automatically at boot/shutdown on my Mac. I can't get it to work at all. This is my first time trying to get script runs on Startup/Shutdown, so it could be that I'm just missing something very basic and if that's the case I apologize.
These are the steps I followed:
Created a directory /Library/StartupItems/HeadlessVM
Created two files within that directory:
-rwxr--r-- 1 root wheel 242 Feb 19 19:05 HeadlessVM
-rw-r--r-- 1 root wheel 188 Feb 20 12:42 StartupParameters.plist
Contents for HeadlessVM
$ cat HeadlessVM
#!/bin/sh
. /etc/rc.common
StartService ()
{
ConsoleMessage "Starting HeadlessVM"
/usr/local/bin/runvmheadless
}
StopService ()
{
ConsoleMessage "Suspending HeadlessVM"
/usr/local/bin/suspendvmheadless
}
RunService "$1"
Contents for StartupParameters.plist
$ cat StartupParameters.plist
{
Description = "Runs/Suspends Virtual Machine Headless on OS X Startup/Shutdown";
Provides = ("HeadlessVM");
Uses = ("Disks");
OrderPreference = ("Late");
}
Created my script files, that will perform both actions:
-rwxr-xr-x# 1 xxxxxxx admin 164 Feb 19 01:06 runvmheadless
-rwxr-xr-x# 1 xxxxxxx admin 160 Feb 19 01:19 suspendvmheadless
Contents for runvmheadless
$ cat runvmheadless
#!/bin/bash
"/Applications/VMware Fusion.app/Contents/Library/vmrun" -T fusion start "/Volumes/Archive/Virtual Machines/vm.vmwarevm/vm.vmx" nogui
Contents for suspendvmheadless
$ cat suspendvmheadless
#!/bin/bash
"/Applications/VMware Fusion.app/Contents/Library/vmrun" -T fusion suspend "/Volumes/StaticData/Virtual Machines/vm.vmwarevm/vm.vmx"
My troubleshooting so far:
If I run the scripts from the terminal, they work as intended.
If I run sudo /sbin/SystemStarter (start or stop) "HeadlessVM" it also works.
On console I only see the following when I reboot, no clue on what's wrong tho.
2/20/12 12:11:09.128 PM SystemStarter: Runs/Suspends Virtual Machine Headless on OS X Startup/Shutdown (100) did not complete successfully
Appreciate any help, Thank you.
I found what was wrong. The code above is fine, the problem is that my scripts are trying to get data from an encrypted secondary disk which was not available at boot time.
I used this in order to bypass this problem:https://github.com/jridgewell/Unlock
Thanks