running own C file in crontab

Hi all,

again, top line apologies for noobish questions.

I have taken up programming C, in linux, and have written a C file that basically does some calculations then runs a system(); command to open a file through shellscript.

I have used GCC to compile update.c -o ./runupdate

I have also set up a cron job /10 * * * * bash -c “/home/programs/runupdate”

However, the cron job fires with no output from the executable. I think I might be missing something in the way cron is executing the file?

Advice would be much appreciated. Thanks.

I take it your runupdate file is executable and has been tested manually (not triggered by cron) … so this is purely a cron problem ?

I take it you’ve checked the logs to see that the cron job has been triggered ?

Which distro/version/architecture ?


yes, running the executable with exec command works fine.

The syslog shows the cron firing exactly when it should.

The system is Raspbian wheezy on ARM6 architecture (Raspberry Pi)

So what exactly do you enter at the command line to run the programme

I run as root:

exec /home/programs/runupdate

Looking a it in depth last night, I was wondering if it might actually be running the executable fine, but not able to run the system() command.

The command I am trying to run from within the executable is “/usr/lib/programs/libreoffice/soffice.bin --show /home/pres/Week3.odp”
The reason it’s in an executable is, it needs to calculate the week number of the presentation to open before it sends the command.
The exec command runs the executable and loads the presentation fine, but even when I run that command as a shell script in cron, it doesn’t work.

Is there a limit as to the functionality of cron, whereby I can’t load libreoffice Impress as part of a cron job?

Nope, no limit to cron … if you can run it from the command line you can run it from cron.

I’d guess this is either

a) a problem with the command itself (that you’re running from cron)
maybe try

bash -c "exec /home/programs/runupdate"

test that from the command line first.


b) an ownership/permission issue, where cron can’t run the command with elevated privileges.

If the file is executable (you’ve already run chmod +x against it), then why do you need to call “exec” at all? Why not call the program directly?

If I run the executable directly without exec command, I get blank line syndrome in the terminal (ie. the cursor drops down to the next line, but no prompt and no matter what you type, enter is just a carriage return. Nothing loads)

I will try to bash the command in the cron job tonight, and see if that works. What does the -c argument do exactly?



-c string If the -c option is present, then commands are read from string.

It says the following string is the string to be entered as the command.


man bash

Is it supposed to run like that? I mean, is it supposed to run constantly, or execute a process then terminate?
I’m a very novice C programmer, but I think if you end it with “return 1” on the last line, it will terminate properly…?

Or that could be bash ::slight_smile:

I have found out that the executable is actually running as it opens up libreoffice. However, the ‘libreoffice’, ‘sh’, and ‘oosplash’ tasks are present in the task manager, but not doing anything.

This is quite frustrating. If I run the same command from terminal, it works fine. If I do it from Cron, it loads libreoffice, but not the GUI.