Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


Command works at command line but not from cron


Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Command works at command line but not from cron

Oracle Linux 6.
Trying to set up a simple monitoring of memory usage. This command does exactly what I want at the command line:

Code:
echo $(date +%Y-%m-%d" "%H:%M:%S) $(grep PageTables /proc/meminfo) >> /home/oracle/meminfo.log

But when I put it in my crontab:

Code:
* * * * *  echo $(date +%Y-%m-%d" "%H:%M:%S) $(grep PageTables /proc/meminfo) >> /home/oracle/meminfo.log

It fails and I get this in my mail

Code:
/bin/sh: -c: line 0: unexpected EOF while looking for matching `)'
/bin/sh: -c: line 1: syntax error: unexpected end of file

# 2  
man crontab yields :
Code:
The ``sixth'' field (the rest of the line) specifies the command to be run.  The entire command portion of the line, up to a newline  or  %
       character,  will be executed by /bin/sh or by the shell specified in the SHELL variable of the cronfile.  Percent-signs (%) in the command,
       unless escaped with backslash (\), will be changed into newline characters, and all data after the first % will be sent to the  command	as
       standard input

This User Gave Thanks to vgersh99 For This Post:
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Cp command works on command line but not in bash
cmccabe
The below command moves all the .vcf files into the directory. cp /home/cmccabe/Desktop/test/vcf/overall/stats/*.vcf /home/cmccabe/Desktop/NGS/annovar When I use a bash wrapper the target.txt gets created but the text files do not get copied. All the paths are the same, but not sure why...... Shell Programming and Scripting
2
Shell Programming and Scripting
SH script, variable built command fails, but works at command line
oly_r
I am working with a sh script on a solaris 9 zone (sol 10 host) that grabs information to build the configuration command line. the variables Build64, SSLopt, CONFIGopt, and CC are populated in the script. the script includes CC=`which gcc` CONFIGopt=' --prefix=/ --exec-prefix=/usr...... Shell Programming and Scripting
8
Shell Programming and Scripting
s3cmd works on command line not on cron
qwerty20
Ubuntu 9.10 is my linux distro Based on forums they say that the problem is with environment . here is my case: login as user, then sudo -s using this command: s3cmd put file s3://bucket >>worked! now here is the simple script intended for testing: #! /bin/bash env >/tmp/cronjob.log...... Shell Programming and Scripting
1
Shell Programming and Scripting
Cron job fails, but works fine from command line
cdunavent
I have a very basic script that essentially sends a log file, via FTP, to a backup server. My cron entry to run this every night is: 55 23 * * * /usr/bin/archive_logs The script runs perfectly when executed manually, and actually worked via cron for about three weeks. However, it mysteriously...... Shell Programming and Scripting
3
Shell Programming and Scripting
script works on command line, not in cron job
JackTheTripper
Hey there, I'm a total newbie unix guy here and just picking this stuff up. Have a very small script I put together that works fine from the command line but not once I put it in a cron job. Searched and found this thread and am wondering it it has something to do with setting variables, though the...... UNIX for Dummies Questions & Answers
7
UNIX for Dummies Questions & Answers

Featured Tech Videos