LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cant make crontab work. (https://www.linuxquestions.org/questions/linux-newbie-8/cant-make-crontab-work-4175433876/)

joham34 10-24-2012 11:24 AM

cant make crontab work.
 
Hello everybody.
I use an indexing program called recoll. I want to run recollindex (a command to force indexing update) at startup. From the command line I just have to type recollindex and it works perfectly
I have added various lines in my crontab :
Code:

@reboot /home/ioannis/bin/recollscript

@reboot /usr/bin/recollindex


@reboot /usr/bin/chromium-browser

recollscript is a simple script I created with 777 permissions that works pefectly from the command line
I just added the chromium-browser line just to make sure the problem was not in my commands
Yet nothing is executed

When giving
Code:

~$ sudo grep CRON /var/log/syslog
I get:

Code:

Oct 24 18:58:29 ioannis-desktop CRON[1186]: (ioannis) CMD (/home/ioannis/bin/recollscript)
Oct 24 18:58:29 ioannis-desktop CRON[1187]: (root) CMD (recollindex)
Oct 24 18:58:29 ioannis-desktop CRON[1212]: (ioannis) CMD (/usr/bin/chromium-browser)
Oct 24 18:58:29 ioannis-desktop CRON[1236]: (ioannis) CMD (/usr/bin/recollindex)
Oct 24 18:58:29 ioannis-desktop CRON[1138]: (ioannis) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
Oct 24 18:58:29 ioannis-desktop CRON[1139]: (ioannis) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
Oct 24 18:58:29 ioannis-desktop CRON[1137]: (ioannis) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
Oct 24 18:58:29 ioannis-desktop CRON[1140]: (root) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
Oct 24 19:17:01 ioannis-desktop CRON[5739]: (root) CMD (  cd / && run-parts --report /etc/cron.hourly)

(they are the just the last few lines)
Any help would be greatly appreciable

unSpawn 10-24-2012 12:49 PM

Please remove the /home/ioannis/bin/recollscript and /usr/bin/chromium-browser lines and see this advice?

medoc 10-24-2012 02:27 PM

What makes you think that recollindex does not run actually ? Do you get an error indication somewhere ?

medoc 10-24-2012 02:34 PM

The "this advice" link above is not relevant, this would only be an issue for the real time indexer daemon (recollindex -m). The batch mode does not care about an X server.

joham34 10-24-2012 11:56 PM

Quote:

Originally Posted by medoc (Post 4814062)
What makes you think that recollindex does not run actually ? Do you get an error indication somewhere ?

I add a number in one of my files indexed before rebooting and after startup is not found by recall but gets found immediately after either running recollindex or recollscript. So I know it isnt executed

joham34 10-25-2012 12:33 AM

Quote:

Originally Posted by unSpawn (Post 4813995)
Please remove the /home/ioannis/bin/recollscript and /usr/bin/chromium-browser lines and see this advice?

I tried everything above, no difference

medoc 10-25-2012 12:42 PM

Ok, then I'd try to set up the recoll debug log and see if anything gets in there.

In ~/.recoll/recoll.conf:

loglevel = 6
logfilename = /tmp/rcltrace

Then reboot and see if anything gets in there (it's reset by every recoll command so you have to take a look before you do anything else with recoll).

Don't forget to reset the log level to 3 after, otherwise the log can get quite big.

If there is nothing in the log, I think that we can assume that recollindex does not start at all. Any special security feature activated on the system ?

I tried to do the exact same thing that you do by the way, it works for me, on a vanilla ubuntu 12.04 system.

joham34 10-26-2012 02:13 PM

Quote:

Originally Posted by medoc (Post 4814794)
Ok, then I'd try to set up the recoll debug log and see if anything gets in there.

In ~/.recoll/recoll.conf:

loglevel = 6
logfilename = /tmp/rcltrace

Then reboot and see if anything gets in there (it's reset by every recoll command so you have to take a look before you do anything else with recoll).

Don't forget to reset the log level to 3 after, otherwise the log can get quite big.

If there is nothing in the log, I think that we can assume that recollindex does not start at all. Any special security feature activated on the system ?

I tried to do the exact same thing that you do by the way, it works for me, on a vanilla ubuntu 12.04 system.

Thanks for your answer. Interestingly indexing at startup worked initially for some days when I gave the command in startup applications, then stopped working without apparent reason. Thats why I tried
Code:

crontab -e
I did as you said and here is what I got
Code:

:4:../utils/execmd.cpp:185:ExecCmd::startExec: (0|0) /usr/bin/ionice {-c} {3} {-p} {4142}
:4:../utils/execmd.cpp:467:ExecCmd::wait: got status 0x0
:4:../rcldb/rcldb.cpp:602:Db::open: m_isopen 0 m_iswritable 0
:5:../rcldb/stoplist.cpp:36:StopList::StopList: file_to_string(/home/ioannis/.recoll/stoplist.txt) failed: open/stat: errno: 2 :
:4:../rcldb/rcldb.cpp:634:Db::open: lastdocid: 17180
:4:../index/fsindexer.cpp:103:FsIndexer::index: Indexing /media/SUNDISK/AAPHF into /home/ioannis/.recoll/xapiandb
:2:../index/fsindexer.cpp:124:FsIndexer::index: error while indexing /media/SUNDISK/AAPHF: stat(/media/SUNDISK/AAPHF) : 2 : No such file or directory

:4:../rcldb/rcldb.cpp:581:Db::~Db: isopen 1 m_iswritable 1
:4:../rcldb/rcldb.cpp:696:Db::i_close(1): m_isopen 1 m_iswritable 1
:4:../rcldb/rcldb.cpp:706:Rcl::Db:close: xapian will close. May take some time
:4:../rcldb/rcldb.cpp:711:Rcl::Db:close() xapian close done.

Now the green line shows the problem: My directory (which is in a flash drive) does exist and is read when I give "recollindex" from the command line, yet here, it is stated that it does not exist. There is no possibility of some error in describing the directory as I added it from the GUI.
So it appears it is not a cron problem but rather recoll fails to read the directory.
Any idea?

medoc 10-27-2012 12:46 AM

Quote:

Any idea?
Well, yes, the stat(/media/SUNDISK/AAPHF) : 2 : No such file or directory message is a direct translation of a stat(2) system call. So if it says no such file or directory, this must be true.

Your removable volume is quite probably not yet mounted at this point of the machine startup.

I'd try to write a small shell script with a loop to test the existence of the volume then start recollindex, and start this from cron...

while test ! -d /media/SUNDISK/AAPHF; sleep 1;done
/usr/bin/recollindex

Cheers,

jf

joham34 10-27-2012 09:27 AM

Thanks
 
Quote:

Originally Posted by medoc (Post 4815953)
Well, yes, the stat(/media/SUNDISK/AAPHF) : 2 : No such file or directory message is a direct translation of a stat(2) system call. So if it says no such file or directory, this must be true.

Your removable volume is quite probably not yet mounted at this point of the machine startup.

I'd try to write a small shell script with a loop to test the existence of the volume then start recollindex, and start this from cron...

while test ! -d /media/SUNDISK/AAPHF; sleep 1;done
/usr/bin/recollindex

Cheers,

jf

Thanks a lot, you relieved my headache!
My HD is SSD , may be it explains why my flashdrive is not mounted when crontab is read, SSD is really fast
I ll mark the thread as solved
The test script didnt work and for the shake of readers of these lines in the future, a do should be included and no blank space between ! and -d should exist
Code:

while test !-d /media/SUNDISK/AAPHF; do sleep 1;done
What worked fine was just to put a line
Code:

01 * * * * recollscript
in my crontab file so it runs every hour, it comforts me very well
Cheers
Ioannis

medoc 10-28-2012 02:28 AM

Sorry about the missing do, will test before I post next time. But there is definitely a space between the ! and the -d. You can't try it on the command line though as bash will take the ! for a history reference. So here goes the tested script, which will take the target directory as a parameter:

Code:

#!/bin/sh

if test $# -ne 1 ; then
    echo "Usage: testdir.sh <dirname>" 1>&2
    exit 1
fi

while test ! -d $1;do
    sleep 1
done

recollindex


joham34 10-28-2012 12:09 PM

Quote:

Originally Posted by medoc (Post 4816551)
Sorry about the missing do, will test before I post next time. But there is definitely a space between the ! and the -d. You can't try it on the command line though as bash will take the ! for a history reference. So here goes the tested script, which will take the target directory as a parameter:

Code:

#!/bin/sh

if test $# -ne 1 ; then
    echo "Usage: testdir.sh <dirname>" 1>&2
    exit 1
fi

while test ! -d $1;do
    sleep 1
done

recollindex


Yes you are right the blank space between ! and -d. I am struggling to learn well how to use these operators and tests in general. I constantly forget things. Difficult to remember when you are 48 ;-)


All times are GMT -5. The time now is 10:48 PM.