Subscribe

Get the Network Administrators tool pack

Subscribe to our newsletter and get 11 free network administrator tools, plus a 30 page user guide so you can get the most out of them.

Click Here to get your free tools

Recent Posts

Search

Archives

Windows Cron Service – Version 2.0

Post image for Windows Cron Service – Version 2.0

by Steve Wiseman on May 16, 2012 · 75 comments

in Tips,Tools,Utility


.

Back in November we released a free cron service for windows

What is it?

It is a task scheduler that uses the same format as the unix cron service.

Clock

The motivation for this tool was that the task scheduler built into windows did not have a good way of moving jobs from one computer to another.

With our cron service, you can setup your list of jobs and easily copy the ‘crontab’ file to other servers – the cron service instantly sees the change. No messing around in the registry.

A few problems with 1.0:

-It did not recognize vbs or bat files, so you would have to go through all kinds of trouble to get the command line right

-The logging was not very good, so it was hard to see if a job failed

-All processes executed in the service context. That means you can never run a visual application, and your scripts cannot access network drives.

-No easy way to edit the file – Just notepad.exe. Why not have a nice job editing tool?

With 2.0 we fixed that and more

The first thing we did was add a bunch of execution options. With your job you can:

-Run the job in all active remote desktop sessions

-Run the job in the console session

-Run the job as the current user, or as an administrator

-Run the job in the console, even if no one is logged on. Like this:

Why would you need that?

Think of all the scripts you wish you could run that either need to at least show one small progress window…or access a network drive – even if a user was logged off.

Now with IntelliAdmin Cron 2.0 you can do it.

I bet you are thinking:

“Man that would be cool if remote execute in Network Administrator could do that.”

Yea, we thought so too. All of these options will be added to the Remote Execute action of Network Administrator in a few weeks – Buy it now and it will be a free update.

Included with this version is a crontab edit application. It makes it a breeze to edit your jobs:

Cron Edit Tool

If you forget the crontab format, it has a cheat sheet included…so you don’t have to browse around trying to figure it out:

The new service uses log rotation, so the log files will never threaten to take up too much disk space:

Status.log – List of the latest job runs and the result

Error.log – Any errors encountered are reported here

The service watches the crontab file, so all changes are immediate.

If you want to create the crontab file manually, you can find more about it here

We have made a change to the format (It will accept the old format too) to accommodate our execution options.

A typical line in your crontab will look like this:

* * * * * "c:\temp\test.vbs"

The new format has an integer value right before the path of the program to execute:

* * * * * 121 "c:\temp\test.vbs"

Here are the execution options that make up that value:

1 = The process is executed as an administrator
2 = The process is executed as the session user
4 = The process is hidden when executed
8 = The process is executed in the console session
16 = The process will only be executed if someone is logged into the console
32 = The process will be executed in all RDP sessions.
64 = The will disable the job

If you wanted the program to run as administrator in all the current RDP sessions you would use: 33

This is calculated by adding the options together…32+1

If you wanted the program to run in the console as the current user, but only if someone was logged in, it would be: 2 + 16 + 8 = 26

Finally, we made this app as tight as possible. The service app is a little under 150K. If you want to install it without our setup, just copy the icronsvr.exe to the folder you want it in, and install it like this from the command line:

icronsvr.exe install icronsvr

The second argument is the service name..don’t forget to include that.

If you want to remove it use this:

icronsvr.exe uninstall icronsvr

The crontab edit tool just needs to be run in the same folder as the crontab file, but is not required for its operation.

Finally, this is totally free for commercial and personal use.

Click here to get it now from our download page.

Enjoy the IntelliAdmin software goodnees – and as always no spyware or badware.

One more thing…Subscribe to my newsletter and get 11 free network administrator tools, plus a 30 page user guide so you can get the most out of them. Click Here to get your free tools

Related Articles:

{ 25 comments… read them below or add one }

1 Jim November 11, 2012 at 4:01 pm

Very nice!

I could be wrong, but I think the earlier question from Relinson was about not wanting the job to launch again if the current one is still running, and I know that is my desire at times. It comes up, for example, when using the scheduler to run a fairly frequent polling job with an unknown amount of work to do, and I believe is how windows task manager behaves. It would be nice to have this as an option.

2 Steve Wiseman November 11, 2012 at 11:38 pm

Thanks for taking the time to comment Jim. Totally agree here. We will make sure to put this on the request list as well.

3 Marty December 3, 2012 at 10:50 am

Great Utility!

Any tips on how to deploy this remotely to hundreds of workstations? Tried just copying the folder but that didn’t put the services on the machine. Tried running the serviceapp installer from cli, that didn’t put the service in the services list either. Must be doing something wrong.

4 Brian January 12, 2013 at 4:39 pm

Hi Steve,

I noticed you mentioned it was going to be included with Network Administrator, but have not seen it make its way there yet. Is this still the plan?

Thanks for the great tools!

5 Steve Wiseman January 16, 2013 at 10:54 am

Hi Brian,

Actually it has. What I meant was the remote execute engine. The ability to launch into another session..or as a service. It is all in the current version of Network Administrator under the remote execute plugin.

Thanks,

Steve

6 Jim March 11, 2013 at 2:51 pm

Where are the log files stored? I’m not seeing any and am wondering if I’m looking in the wrong place, missing a flag or argument?

7 Steve Wiseman March 11, 2013 at 8:04 pm

There should be a log file in the same folder as the installation directory.

Thanks,

Steve

8 mynth April 3, 2013 at 8:34 am

Since you are asking for suggestions for version 3 here are my 2 cents:
– option to set working dir
– help file with detailed description of options
– option to run script from scripts list (eg. r-click > run now)
– option to add description (can be saved as comment in crontab)
– option to group scripts (grouping can be saved as comment in crontab)

9 Michael April 25, 2013 at 8:00 pm

Is there any way to specify the location of the crontab file? I’d like to put it somewhere other than buried under Program Files. Thanks.

10 Rob June 16, 2013 at 5:45 am

I seem to be having difficulty in restricting the jobs to run only on Sundays. Wouldn’t I just enter 0 in the “Days of the Week” field? I’ve tried toggling between different values including restricting Mondays (/1)etc. but the scripts seem to always run regardless the day. Any ideas?

11 Aleksey Sergeyev September 9, 2013 at 1:11 am

First of all, I would like to thank mr. Wiseman, because product is really great.

Suggestions:
– option for config file location(crontab)
– option for error log file location(error.log)
– option for staus log file location(status.log)
– all suggested options are command line options

12 Kilburn September 12, 2013 at 2:37 am

I have a cmd script that will just flash up at the specified time but not actaully run. The script calls rsync whihc runs under cygwin.

When you excute the script manually in a windows command console, the cmd script runs fine.

Could anyone help

13 Andrew September 12, 2013 at 11:43 am

Please open source this project. It’s been well over a year since the last release and is a solid implementation – but should be open to community contribution and improvements!

14 Tim October 13, 2013 at 7:36 pm

Do you support comments within the CRONTAB file? Another version of acron service I used to use allowed for comments via a “#” character at the beginning of a line. Comments can be very handy for really big and multi-use CRTONTAB files.

15 Nico November 6, 2013 at 8:09 am

Hello,

I’ve got a problem to set a Job to a specified day of the month like this:

53 12 6 * * 1 “D:\batch\blabla.cmd”

It should have been executed on the 6th every month at 12:53h, but it doesn’t work.

When I change the “6” to “*” then it works, but every day and that’s not my goal.

Any hints?

16 Steve Wiseman November 8, 2013 at 12:17 pm

Hi Nico,

You are right. There is a bug.

I had someone take a look, and fix the issue.

Try this new download link:

http://ftp.intelliadmin.com/beta/iadmincron.exe

The website has been updated with this version as well…but the above link gets around the signup 🙂

Steve

17 Brent Carnegie December 3, 2013 at 5:25 pm

I want the jobs to run as a domain admin as they will access remote servers. I have tried setting the service to run as the domain admin account but still no luck. Any ideas?

18 Transistor April 2, 2014 at 3:26 pm

I’m trying to cron a PHP script on my WIMP server. It doesn’t seem to work as IntelliAdmin Cron Service is running as “Local System” which doesn’t have permission to run PHP.EXE.
What’s the best fix for this?

Many thanks for a very useful app.

19 Steve Wiseman April 2, 2014 at 5:15 pm

It should run your script. The only limitation is that it can’t connect to network shares. What type of error are you seeing in the log (The log files should be in the same folder as the cron exe)

Thanks,

Steve

20 Transistor April 2, 2014 at 6:02 pm

Thanks, Steve. Status.log returns:
Executed [C:\PHP\php.exe] with arguments [c:\inetpub\wwwroot\myscript.php] Session ID: 0 Return Code: 0

Here’s my crontab. (Note devious means of including comments!)
1 1 1 1 1 64 “# Run PHP with myscript.php”
* * * * * 1 “C:\PHP\php.exe” c:\inetpub\wwwroot\myscript.php

Note: I can run the script from the command line. I have also tried calling it via a batch file. The batch file runs but the PHP script doesn’t.

By the way, is there a way to get it to pop up a window so I can see the script run? It’s not quite clear to me from the manual above.

Thanks again.

21 Steve Wiseman April 3, 2014 at 2:33 am

Try this. Use the cron tab settings app and tell it to Execute in the console session. Run it through a bat file with a pause. This should bring up a window in the console session.

22 Transistor April 3, 2014 at 6:10 pm

Following on …
I have succeeded in getting the cron task running with
* * * * * 33 “C:\PHP\php.exe” c:\inetpub\wwwroot\myscript.php
but I had to create a local user (CronUser) and give it file system security privileges on both php.exe and (for convenience) the whole web directory tree.

Is this what I should expect?

Also, why do I get two records in status.log? e.g.,
[…] Executed [C:\PHP\php.exe] with arguments [c:\inetpub\wwwroot\myscript.php] Session ID: 2 Return Code: 0
[…] Executed [C:\PHP\php.exe] with arguments [c:\inetpub\wwwroot\myscript.php] Session ID: 0 Return Code: 0

Thank you.

23 Matthias Lange July 9, 2014 at 11:23 am

Hello,

my cronjobs are always executed twice. What is wrong?

my crontab:
* * * * * 33 “C:\Perl64\bin\perl.exe” C:\Scripts\channelstat.pl

my status.log:
[2014/07/09 – 16:54:00] Executed [C:\Perl64\bin\perl.exe] with arguments [C:\Scripts\channelstat.pl] Session ID: 2 Return Code: 0
[2014/07/09 – 16:54:00] Executed [C:\Perl64\bin\perl.exe] with arguments [C:\Scripts\channelstat.pl] Session ID: 0 Return Code: 0

24 Steve Wiseman July 13, 2014 at 11:53 pm

You have option 33 which tells it to execute in all sessions. Looks like it is executing in session zero, and session 2.

Change it to 1 instead of 33 and it will run once.

25 ItsMe June 22, 2015 at 2:32 am

We had problems with the cron utility, after weeks of running fine it suddenly stopped with workin, and no way to start it again without rebooting the server. After further investigation and searching on the error code it seems that the problem is as described in the following blog: http://blog.ylnotes.com/winfix-error-0xc0000142-windows-task-scheduler-fails-to-run-in-batch-mode/
We now have to wait for a few weeks to see if this was the result.

Leave a Comment

Category Links - Windows Forum - Exchange Forum