# crontab test - touch file

**URL:** <https://forums.suse.com/t/crontab-test-touch-file/28000>\
**Category:** SLES Configure-Administer\
**Created:** [March 16, 2016, 3:05pm UTC](https://forums.suse.com/t/crontab-test-touch-file/28000 "2016-03-16T15:05:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wlourens](https://avatars.discourse-cdn.com/v4/letter/w/87869e/32.png) [@wlourens](https://forums.suse.com/u/wlourens)\
**Post date:** [March 16, 2016, 3:05pm UTC](https://forums.suse.com/t/crontab-test-touch-file/28000/1 "2016-03-16T15:05:55Z")

</div>

Hi

I would like to test if crontab is running with a simple continues touch file, but it is not working:

Crontab entry:

01 \* \* \* \* /usr/sap/BHA/HDB00/willem/testcron.bat \>\> /usr/sap/BHA/HDB00/willem/cronout.txt

File entry:

hanaprd-mgmt:HDB:bhaadm /usr/sap/BHA/HDB00/willem 1046\> cat /usr/sap/BHA/HDB00/willem/testcron.bat  
#!/bin/bash  
touch /usr/sap/BHA/HDB00/willem/testcron.txt

Date of files not updated:

hanaprd-mgmt:HDB:bhaadm /usr/sap/BHA/HDB00/willem 1047\> ls -ltr  
total 4  
-rwxrwxrwx 1 bhaadm sapsys 0 Mar 16 13:53 cronout.txt  
-rwxrwxrwx 1 bhaadm sapsys 57 Mar 16 13:56 testcron.bat  
-rwxrwxrwx 1 bhaadm sapsys 0 Mar 16 15:01 testcron.txt

This is SUSE linux 11.2

Advise will be appreciated.

---

<div class="post-metadata">

**Author:** ![ab1](https://avatars.discourse-cdn.com/v4/letter/a/d2c977/32.png) [@ab1](https://forums.suse.com/u/ab1)\
**Post date:** [March 16, 2016, 3:37pm UTC](https://forums.suse.com/t/crontab-test-touch-file/28000/2 "2016-03-16T15:37:39Z")

</div>

On 03/16/2016 07:14 AM, wlourens wrote:[color=blue]

> I would like to test if crontab is running with a simple continues touch  
> file, but it is not working:
> 
> Crontab entry:[/color]

Please use the CODE button to put things like code in un-parsed blocks. I  
think the button looks like the ‘#’ symbol below the message text field.  
[color=blue]

> 01 \* \* \* \* /usr/sap/BHA/HDB00/willem/testcron.bat \>\>  
> /usr/sap/BHA/HDB00/willem/cronout.txt[/color]

Please do not name files with the .bat extension; it implies something  
that is not case, namely that this file is made for a windows interpreter.  
File extensions do not really matter in the Linux/Unix world, but if you  
are going to use one, use the right one (.sh in this case).  
[color=blue]

> File entry:
> 
> hanaprd-mgmt:HDB:bhaadm /usr/sap/BHA/HDB00/willem 1046\> cat  
> /usr/sap/BHA/HDB00/willem/testcron.bat  
> #!/bin/bash  
> touch /usr/sap/BHA/HDB00/willem/testcron.txt
> 
> Date of files not updated:
> 
> hanaprd-mgmt:HDB:bhaadm /usr/sap/BHA/HDB00/willem 1047\> ls -ltr  
> total 4  
> -rwxrwxrwx 1 bhaadm sapsys 0 Mar 16 13:53 cronout.txt  
> -rwxrwxrwx 1 bhaadm sapsys 57 Mar 16 13:56 testcron.bat  
> -rwxrwxrwx 1 bhaadm sapsys 0 Mar 16 15:01 testcron.txt[/color]

Is there a really good reason that permissions are set to 777 on these  
files? Maybe it was just for testing to rule out permissions problems,  
but this is generally a bad idea. What kind of filesystem do you have  
here, and how is it mounted?  
[color=blue]

> This is SUSE linux 11.2[/color]

I presume you mean SUSE Linux Enterprise Server SP2. Just to be clear,  
while openSUSE uses the 11.2, 13.1, etc. versioning, SLES only puts the  
major version followed by SP whtaever. There are some implied meanings as  
a result, but part of the reason I mention it here is that there was an  
openSUSE 11.2 way back in the day too, so your versioning could imply an  
ancient version of that.

I am not sure why you think the files are not being updated, so please  
help me understand what you expected to see above. The timestamp of  
testcron.txt is from 15:01, which per your crontab entry is when this  
should have run (unless it also ran at 16:01, but there is no way to know  
that from what you provided). If your last edits were at 13:56, then this  
could have executed at 14:01 (created the file), and then 15:01 (updated  
the file) which is what we see above.

I presume you have tested the ‘touch’ command manually to ensure that  
timestamps change as you expect when not using cron. If not, please do so  
just in case your filesystem is not going to update timestamps for some  
odd reason.

I presume you entered your crontab line using the ‘crontab -e’ command to  
do this as some user. Which user was that? The permissions on your files  
make it such that maybe it will not matter (as long as parent directory  
permissions are not preventing access to bhsadm or sapsys members), but  
knowing for sure is important. When you do your test of ‘touch’ outside  
of crontab, be sure that you use the same user as you expect cron to use.

–  
Good luck.

If you find this post helpful and are logged into the web interface,  
show your appreciation and click on the star below…

---

<div class="post-metadata">

**Author:** ![georgeston](https://avatars.discourse-cdn.com/v4/letter/g/5e9695/32.png) [@georgeston](https://forums.suse.com/u/georgeston)\
**Post date:** [March 16, 2016, 4:41pm UTC](https://forums.suse.com/t/crontab-test-touch-file/28000/3 "2016-03-16T16:41:55Z")

</div>

Not sure what is wrong but you can try:

Specify full path of touch in your batch file.

For better debugging, redirect stderr to the same text file, i.e.:  
01 \* \* \* \* /usr/sap/BHA/HDB00/willem/testcron.bat \>\> /usr/sap/BHA/HDB00/willem/cronout.txt 2\>&1

[QUOTE=wlourens;31897]Hi

I would like to test if crontab is running with a simple continues touch file, but it is not working:

Crontab entry:

01 \* \* \* \* /usr/sap/BHA/HDB00/willem/testcron.bat \>\> /usr/sap/BHA/HDB00/willem/cronout.txt

File entry:

hanaprd-mgmt:HDB:bhaadm /usr/sap/BHA/HDB00/willem 1046\> cat /usr/sap/BHA/HDB00/willem/testcron.bat  
#!/bin/bash  
touch /usr/sap/BHA/HDB00/willem/testcron.txt

Date of files not updated:

hanaprd-mgmt:HDB:bhaadm /usr/sap/BHA/HDB00/willem 1047\> ls -ltr  
total 4  
-rwxrwxrwx 1 bhaadm sapsys 0 Mar 16 13:53 cronout.txt  
-rwxrwxrwx 1 bhaadm sapsys 57 Mar 16 13:56 testcron.bat  
-rwxrwxrwx 1 bhaadm sapsys 0 Mar 16 15:01 testcron.txt

This is SUSE linux 11.2

Advise will be appreciated.[/QUOTE]

---

<div class="post-metadata">

**Author:** ![Jens-U](https://avatars.discourse-cdn.com/v4/letter/j/d78d45/32.png) [@Jens-U](https://forums.suse.com/u/Jens-U)\
**Post date:** [March 16, 2016, 7:56pm UTC](https://forums.suse.com/t/crontab-test-touch-file/28000/4 "2016-03-16T19:56:07Z")

</div>

Hi Willem,

> 01 \* \* \* \* /usr/sap/BHA/HDB00/willem/testcron.bat \>\> /usr/sap/BHA/HDB00/willem/cronout.txt

I advise against leading zeros, as these typically are meant to specify octal numbers… starting on “08” might lead to an interpreter error (as “08” is no valid octal number).

The above line (which is most likely from the user crontab, not from /etc/crontab) seems to actually work: It specifies to run the command on every full hour plus one minute. Looking at your “ls” output shows

> -rwxrwxrwx 1 bhaadm sapsys 0 Mar 16 15:01 testcron.txt

hence the file was last updated/touched on 15:01, which seems fine.

If you want to touch the file on every minute, please use “\* \* \* \* \* /usr/sap/BHA/HDB00/willem/testcron.bat \>\> /usr/sap/BHA/HDB00/willem/cronout.txt”

Regards,  
Jens

---

<div class="post-metadata">

**Author:** ![wlourens](https://avatars.discourse-cdn.com/v4/letter/w/87869e/32.png) [@wlourens](https://forums.suse.com/u/wlourens)\
**Post date:** [March 18, 2016, 7:21am UTC](https://forums.suse.com/t/crontab-test-touch-file/28000/5 "2016-03-18T07:21:45Z")

</div>

[QUOTE=jmozdzen;31903]Hi Willem,

> 01 \* \* \* \* /usr/sap/BHA/HDB00/willem/testcron.bat \>\> /usr/sap/BHA/HDB00/willem/cronout.txt

I advise against leading zeros, as these typically are meant to specify octal numbers… starting on “08” might lead to an interpreter error (as “08” is no valid octal number).

The above line (which is most likely from the user crontab, not from /etc/crontab) seems to actually work: It specifies to run the command on every full hour plus one minute. Looking at your “ls” output shows

> -rwxrwxrwx 1 bhaadm sapsys 0 Mar 16 15:01 testcron.txt

hence the file was last updated/touched on 15:01, which seems fine.

If you want to touch the file on every minute, please use “\* \* \* \* \* /usr/sap/BHA/HDB00/willem/testcron.bat \>\> /usr/sap/BHA/HDB00/willem/cronout.txt”

Regards,  
Jens[/QUOTE]

Thanks Jens, this solved it!!! 😃
