Create log file using crontab as different user not working [duplicate] - bash

If I put the following in crontab -e:
* * * * * date +"%Y-%m-%d" > /home/apps/temp/env.txt
there is no env.txt created.
If I change the above line to:
* * * * * date > /home/apps/temp/env.txt
env.txt is created properly.
How can I format date in cron?

You need to escape each one of the %:
* * * * * date +"\%Y-\%m-\%d" > /home/apps/temp/env.txt
Or even better, remove the quotes and leave like this:
* * * * * date +\%Y-\%m-\%d > /home/apps/temp/env.txt

Related

Cron expression in Spring, validation?

So I need a Cron expression which will run my service in following interval:
-every 2h;
-during work hours 9-17h;
-only on work days MON-FRI;
-every month;
-of every year;
I've come up with this:
#Scheduled(* * 0/2 * * MON-FRI)
public Object updateDB() {
controllerImpl.updateDB();
return new Object();
}
I think the problem here s every 2 hours between 9-17h, isn't it?
Try this:
#Scheduled(* * 9-17/2 * * MON-FRI)
You can try following cron expression:
#Scheduled(* * 9-17/2 ? * MON-FRI)
For future references you can use following to create your cron expression:
https://www.freeformatter.com/cron-expression-generator-quartz.html

sed: replace part of line in text file at recognized character with entire line from another file

I have many sets of corresponding .txt files. I want to recognize a specific character ":" in the first .txt file (text1.txt) and then replace it (and the remainder of the line in text1.txt) with the corresponding line from the other .txt file (text2.txt). I would also like to add an additional character say "*" before the copied value.
text1.txt looks something like this:
*
10.04:60.429
*
*
*
12.023:60.078
*
9.033:60.045
*
9.023:60.062
*
*
and text2.txt looks something like this:
*
11
*
*
*
4
*
10
*
9
*
*
The output should look like this:
*
10.04*11
*
*
*
12.023*4
*
9.033*10
*
9.023*9
*
*
any ideas on the best way to do this with sed?
Below awk script should do
awk 'BEGIN{i=1;j=1}
NR==FNR{text1[i++]=$0;next}
/:/{gsub(/:[^:]*/,"*" text1[j],$0)}
#Note :[^:] looks for the last occurence of : in text1 strings
{j++}1' text2.txt text1.txt
Result
*
10.04*11
*
*
*
12.023*4
*
9.033*10
*
9.023*9
*
*

Ruby, Convert cron range into digit

Using Ruby
I would like that any ranges that appear in a cron to be expanded to the contained numbers in the range ex:
0,5,7,30-35 1,3-8,20 * * * /script.sh
expanded :
0,5,7,31,32,33,34,35 1,3,4,5,6,7,8,20 * * * /script.sh
Any help is appreciated
Assuming that 0,5,7,30-35 1,3-8,20 * * * /script.sh is a string, a simple gsub would work:
str = "0,5,7,30-35 1,3-8,20 * * * /script.sh"
str.gsub(/(\d+)-(\d+)/) { ($1..$2).to_a.join(',') }
#=> "0,5,7,30,31,32,33,34,35 1,3,4,5,6,7,8,20 * * * /script.sh"

rexx reading file data onto panel

can you please suggest me the manual or example codes on how i can read the content of a file to be displayed in a rexx panel.
the number of lines from the file can vary and so cannot use the static manner.
thanks,
Samuel Mathews.
In ZOS to read the file in rexx use the execio command
i.e.
"EXECIO * DISKR myindd (STEM fileContentsVar."
Reads the file into a stem variable (fileContentsVar.0 holds the number of records and
fileContentsVar.1 ... hold the actual data).
You could store the file contents in a ISPF table and display the table using the
TBDispl command
The rexx code will be roughly
address ispexec
'tbcreate myfile names(line)'
do i=1 to fileContentsVar.0
line = fileContentsVar.i
'tbadd myfile'
end
'tbtop myfile'
'tbdispl mypanel'
'tbend myfile'
For an example of a table-panel definition see http://pic.dhe.ibm.com/infocenter/zos/v1r12/index.jsp?topic=%2Fcom.ibm.zos.r12.f54dg00%2Fispzdg8040.htm
A table-panel would look like:
************************************************************
* )Attr *
* # Type(output) Intens(low) Just(asis) Caps(off) *
* )Body *
* -------------------- ????????????????? ----------------- *
* +Command ==>Cmdfld +Scroll ==>_samt+ *
* + *
* This table shows ... *
* *
* Line *
* )Model * ---- The model setion holds the
* #line + * Table display section
* *
* )Init *
* &samt=page *
* )Proc *
* )End *
************************************************************

How do I create a .p12 file in Ruby?

I've looked at the Ruby OpenSSL documentation, but I can't quite figure out the pieces I need to put together to make a .p12 file.
There's also this tutorial, but the comments belie an ambivalence about its correctness.
From ossl_pkcs12.c:
/*
* call-seq:
* PKCS12.create(pass, name, key, cert [, ca, [, key_pbe [, cert_pbe [, key_iter [, mac_iter [, keytype]]]]]])
*
* === Parameters
* * +pass+ - string
* * +name+ - A string describing the key.
* * +key+ - Any PKey.
* * +cert+ - A X509::Certificate.
* * * The public_key portion of the certificate must contain a valid public key.
* * * The not_before and not_after fields must be filled in.
* * +ca+ - An optional array of X509::Certificate's.
* * +key_pbe+ - string
* * +cert_pbe+ - string
* * +key_iter+ - integer
* * +mac_iter+ - integer
* * +keytype+ - An integer representing an MSIE specific extension.
*
* Any optional arguments may be supplied as nil to preserve the OpenSSL defaults.
*
* See the OpenSSL documentation for PKCS12_create().
*/
So (untested and probably incorrect - I am not very familiar with Ruby):
p12 = OpenSSL::PKCS12.create("password", "key", pkey, cert)
p12_bytes = p12.to_der

Categories

Resources