Sponsored Content
Top Forums Shell Programming and Scripting Crontab is not working in printf Post 302758911 by gc_sw on Monday 21st of January 2013 04:09:43 AM
Old 01-21-2013
Crontab is not working in printf

hi, i have a script as:

printf '%s -> %s\n' "$(date '+%Y-%m-%d %H:%M')" "$(/opt/gcsw/status -ne | fgrep 'State:2' | wc)"

which gives output as: 2013-01-18 13:00 -> 80 480 6529 and it is working fine.

now I want to put this into cronjob and write the output to a file in every 5 minutes:
Code:
0,5,10,15,20,25,30,35,40,45,50,55 * * * * printf '%s -> %s\n' "$(date '+%Y-%m-%d %H:%M')" "$(/opt/gcsw/status -ne | fgrep 'State:2' | wc)" >> /var/tmp/gcsw/status.txt

i want to see the output as:
Code:
2013-01-18 13:00 -> 80 480 6529
2013-01-18 13:05 -> 85 480 6529
2013-01-18 13:10 -> 80 423 6329
2013-01-18 13:15 -> 71 460 6129
...

but file is not being updated Smilie i think there is a problem with printf with cronjob. any help?

Last edited by gc_sw; 01-21-2013 at 05:18 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

crontab NOT working

Hi, I have put the following entry in crontab and it is NOT working 1 * * * * && /mybin/myjob.sh As today is Sep 26th, Iam using NF-4 to test. Thanks (2 Replies)
Discussion started by: baanprog
2 Replies

2. Programming

working of printf()

hello all, i came accross an aptitude question .. int main() { int a = 10, b = 20, c = 30; printf("%d\t%d\t%d"); } it gives output 30 20 10 what is the reason of such behaviour of printf(). thank you. (7 Replies)
Discussion started by: zius_oram
7 Replies

3. Solaris

crontab is not working.

I have a script which name is sicaklik.sh It is in the root directory. I can run manually but I want to run automatically every 3 minutes but it is not working. WHY? #whoami root #crontab -l #ident "@(#)root 1.21 04/03/23 SMI" 3 * * * * sh ./sicaklik.sh #ls -l sicaklik*... (6 Replies)
Discussion started by: getrue
6 Replies

4. UNIX for Dummies Questions & Answers

crontab not working

Hi, I had setup crontab to execute my script every day midnight 00:00 Below are the current settings. crontab -l 0 0 * * * /apps/bin/compress.ksh_moht > /dev/null 2>&1 Should it not work? I need help fix this? (8 Replies)
Discussion started by: shifahim
8 Replies

5. Red Hat

crontab is not working!!

I can run manually script of ntopdump.sh but crontab can't run this script very five minutes. # crontab -l */3 * * * * root sh /root/ping.sh */5 * * * * root sh /root/ntopdump.sh # # pwd /root # ls -l total 88 -rwxrwxr-x 1 root root 1645 Jun 14 19:01 anaconda-ks.cfg drwxrwxr-x 2 root... (14 Replies)
Discussion started by: getrue
14 Replies

6. UNIX for Advanced & Expert Users

Crontab not working, please help

Hi, When I set the crontab to run every minute, every hour, it works fine. * * * * * env > /tmp/env.output However I want to run it every day at 8:00 AM and it does not run. * 8 * * * env > /tmp/env.output I ran the 'date' command which says it's 8AM PST and also the 'TZ'... (0 Replies)
Discussion started by: samantha13
0 Replies

7. Linux

Crontab not working

Hi, I know this is a common topic. I'm trying to launch a perl script using a contab -e entry. I've been trying diff options but nothing seems to work: My cron is running: UID PID PPID C STIME TTY TIME CMD root 3755 1 0 Nov27 ? 00:00:00 crond This... (4 Replies)
Discussion started by: krebe
4 Replies

8. Shell Programming and Scripting

Printf %T not working

Dear All, this script was working well enough few days back. Now it started acting up. Could anyone please throw some lights about what may be the reason for it's not working. ts=$( printf "%(%s)T" "now" ) under debug mode this is what I get printf "%(%s)T" "now" ++ printf '%(%s)T'... (4 Replies)
Discussion started by: manas_ranjan
4 Replies

9. Shell Programming and Scripting

Crontab not working

Hi All, I have a script with deatils as : $ ls -ld catch_logs.sh -rwx--x--x 1 muser muser 752 Jun 5 22:36 catch_logs.sh User crontab looks likes: $ crontab -l SHELL=/bin/bash PATH=/sbin:/bin:/usr/sbin:/usr/bin * * * * * /opt/scripts/catch_logs.sh Now if I run this script... (7 Replies)
Discussion started by: Junaid Subhani
7 Replies

10. Red Hat

Crontab is not working

Dear Friends, I have Red Hat Linux Enterprise version 6.3. running SAP and oracle. I have created one crontab for user orasid to execute one job periodically. But it is not executing. I have checked crontab service is running. Please help in the matter. Regards, Bhagawati Pandey (5 Replies)
Discussion started by: BPANDEY
5 Replies
fgrep(1)							   User Commands							  fgrep(1)

NAME
fgrep - search a file for a fixed-character string SYNOPSIS
/usr/bin/fgrep [-bchilnsvx] -e pattern_list [file...] /usr/bin/fgrep [-bchilnsvx] -f file [file...] /usr/bin/fgrep [-bchilnsvx] pattern [file...] /usr/xpg4/bin/fgrep [-bchilnqsvx] -e pattern_list [-f file] [file...] /usr/xpg4/bin/fgrep [-bchilnqsvx] [-e pattern_list] -f file [file...] /usr/xpg4/bin/fgrep [-bchilnqsvx] pattern [file...] DESCRIPTION
The fgrep (fast grep) utility searches files for a character string and prints all lines that contain that string. fgrep is different from grep(1) and from egrep(1) because it searches for a string, instead of searching for a pattern that matches an expression. fgrep uses a fast and compact algorithm. The characters $, *, [, ^, |, (, ), and are interpreted literally by fgrep, that is, fgrep does not recognize full regular expressions as does egrep. These characters have special meaning to the shell. Therefore, to be safe, enclose the entire string within single quotes (a'). If no files are specified, fgrep assumes standard input. Normally, each line that is found is copied to the standard output. The file name is printed before each line that is found if there is more than one input file. OPTIONS
The following options are supported for both /usr/bin/fgrep and /usr/xpg4/bin/fgrep: -b Precedes each line by the block number on which the line was found. This can be useful in locating block numbers by con- text. The first block is 0. -c Prints only a count of the lines that contain the pattern. -e pattern_list Searches for a string in pattern-list. This is useful when the string begins with a -. -f pattern-file Takes the list of patterns from pattern-file. -h Suppresses printing of files when searching multiple files. -i Ignores upper/lower case distinction during comparisons. -l Prints the names of files with matching lines once, separated by new-lines. Does not repeat the names of files when the pattern is found more than once. -n Precedes each line by its line number in the file. The first line is 1. -s Works silently, that is, displays nothing except error messages. This is useful for checking the error status. -v Prints all lines except those that contain the pattern. -x Prints only lines that are matched entirely. /usr/xpg4/bin/fgrep The following options are supported for /usr/xpg4/bin/fgrep only: -q Quiet. Does not write anything to the standard output, regardless of matching lines. Exits with zero status if an input line is selected. OPERANDS
The following operands are supported: file Specifies a path name of a file to be searched for the patterns. If no file operands are specified, the standard input will be used. /usr/bin/fgrep pattern Specifies a pattern to be used during the search for input. /usr/xpg4/bin/fgrep pattern Specifies one or more patterns to be used during the search for input. This operand is treated as if it were specified as -e pattern_list. USAGE
See largefile(5) for the description of the behavior of fgrep when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes). ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of fgrep: LC_COLLATE, LC_CTYPE, LC_MES- SAGES, and NLSPATH. EXIT STATUS
The following exit values are returned: 0 If any matches are found 1 If no matches are found 2 For syntax errors or inaccessible files, even if matches were found. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: /usr/bin/fgrep +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ /usr/xpg4/bin/fgrep +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWxcu4 | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ SEE ALSO
ed(1), egrep(1), grep(1), sed(1), sh(1), attributes(5), environ(5), largefile(5), XPG4(5) NOTES
Ideally, there should be only one grep command, but there is not a single algorithm that spans a wide enough range of space-time tradeoffs. Lines are limited only by the size of the available virtual memory. /usr/xpg4/bin/fgrep The /usr/xpg4/bin/fgrep utility is identical to /usr/xpg4/bin/grep -F (see grep(1)). Portable applications should use /usr/xpg4/bin/grep -F. SunOS 5.11 24 Mar 2006 fgrep(1)
All times are GMT -4. The time now is 10:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy