Sponsored Content
Top Forums Shell Programming and Scripting How to do one line bash schedule task? Post 302760345 by siegfried on Thursday 24th of January 2013 01:05:08 AM
Old 01-24-2013
Bug How to do one line bash schedule task?

This seems to work: https://www.unix.com/shell-programmin...uled-task.html

However, I was hoping to avoid writing a 2 line bat files to invoke my cygwin scripts as a scheduled task (since I'm making lots scheduled tasks).

I was hoping this would work:

Code:
SCHTASKS /CREATE /TN test /TR "C:\cygwin\bin\bash.exe -l -c c:/Users/siegfried/Documents/bin/test.sh >> c:/Users/siegfried/Documents/logs/test.log 2>&1" /ST 23:08 /SC daily

Unfortunately, bash seems to be ignoring my attempts to redirect stdout and stderr.

I've tried both single and double "greater than" signs to make it write to test.log and nothing seems to work. The task runs OK: I just cannot get it to make a log file for me.

The alternative, of course, is to specify the file name of a two line bat for the SCHTASKS/CREATE command and inside that silly two line at file, call c:\cygwin\bin\bash.exe. This works, but then I have to manage these two line bat files.

Thanks
Siegfried
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

comment and Uncomment single task out of multiple task

I have a file contains TASK gsnmpproxy { CommandLine = $SMCHOME/bin/gsnmpProxy.exe } TASK gsnmpdbgui { CommandLine = $SMCHOME/bin/gsnmpdbgui.exe I would like to comment and than uncomment specific task eg TASK gsnmpproxy Pls suggest how to do in shell script (9 Replies)
Discussion started by: madhusmita
9 Replies

2. Shell Programming and Scripting

Parse an XML task list to create each task.xml file

I have an task definition listing xml file that contains a list of tasks such as <TASKLIST <TASK definition="Completion date" id="Taskname1" Some other <CODE name="Code12" <Parameter pname="Dog" input="5.6" units="feet" etc /Parameter> <Parameter... (3 Replies)
Discussion started by: MissI
3 Replies

3. Shell Programming and Scripting

General Q: how to run/schedule a php script from cron jobs maybe via bash from shell?

Status quo is, within a web application, which is coded completely in php (not by me, I dont know php), I have to fill out several fields, and execute it manually by clicking the "go" button in my browser, several times a day. Thats because: The script itself pulls data (textfiles) from a... (3 Replies)
Discussion started by: lowmaster
3 Replies

4. Shell Programming and Scripting

Best way to schedule a task that is be excuted years later

What is the best way to schedule a task that is be executed years later? Like execute a script after 4 years. Is cron the best method for that? Any other option other than cron/at ? :confused: (7 Replies)
Discussion started by: nitin09
7 Replies

5. UNIX for Dummies Questions & Answers

BASH: Change alias to script to add a task

Hi. I use an alias, "homeperm" as shorthand for curl -o. Since most of what I download via cUrl is graphic image files -- jpeg files -- I'd like to be able to change this alias to a script, or use it to invoke a function, which will not only download the file but date-stamp it using Exiv2 in... (4 Replies)
Discussion started by: SilversleevesX
4 Replies

6. Shell Programming and Scripting

How to run Cygwin bash from windows scheduled task?

Hmmm.... I love these forums because I always get great prompt responses and I want to ask a question about running bash on windows. Is that allowed? Now I know I can install cygwin cron and run bash that way. Can I run bash from windows schedule task? How? thanks siegfried (1 Reply)
Discussion started by: siegfried
1 Replies

7. Shell Programming and Scripting

how to print the percentage of task completed on the same line

Hi I have written a utility in shell program for which i want to add a code to display percentage of completion dynamically My scripts runs approx about 30 to 45min , It appends exactly 2000 lines to one of the log file. How to calculate percentage ? I will note the total number of lines... (5 Replies)
Discussion started by: rakeshkumar
5 Replies

8. Shell Programming and Scripting

Schedule task on some date and time.

Hi ! all I am interested to know how to schedule some task, say delete some directory which needs root privileges, please someone suggest me other than crontab Here is a scenario schedule date is 25-09-2013 time 10:00 AM to 11:00 AM delete directory log in following path ... (2 Replies)
Discussion started by: Akshay Hegde
2 Replies

9. Shell Programming and Scripting

Windows Task with Bash script

Hello I have a problem with use bash script in windows task. If I use script by cygwin it's working well. If I use it by Windows task I'm get error Error : ERROR 2 (HY000) at line 2: File '.\xxx.csv' not found (Errcode: 2) Code Line : load data local infile './xxx.csv' REPLACE into... (16 Replies)
Discussion started by: karp
16 Replies

10. Shell Programming and Scripting

How to run several bash commands put in bash command line?

How to run several bash commands put in bash command line without needing and requiring a script file. Because I'm actually a windows guy and new here so for illustration is sort of : $ bash "echo ${PATH} & echo have a nice day!" will do output, for example:... (4 Replies)
Discussion started by: abdulbadii
4 Replies
taskq(9F)																 taskq(9F)

NAME
taskq, ddi_taskq_create, ddi_taskq_destroy, ddi_taskq_dispatch, ddi_taskq_wait, ddi_taskq_suspend, taskq_suspended, ddi_taskq_resume - Ker- nel task queue operations SYNOPSIS
#include <sys/sunddi.h> ddi_taskq_t *ddi_taskq_create(dev_info_t *dip, const char *name, int nthreads, pri_t pri, uint_t cflags); void ddi_taskq_destroy(ddi_taskq_t *tq); int ddi_taskq_dispatch(ddi_taskq_t *tq, void (* func)(void *), void *arg, uint_t dflags); void ddi_taskq_wait(ddi_taskq_t *tq); void ddi_taskq_suspend(ddi_taskq_t *tq); boolean_t ddi_taskq_suspended(ddi_taskq_t *tq); void ddi_taskq_resume(ddi_taskq_t *tq); INTERFACE LEVEL
Solaris DDI specific (Solaris DDI) PARAMETERS
dip Pointer to the device's dev_info structure. May be NULL for kernel modules that do not have an associated dev_info struc- ture. name Descriptive string. Only alphanumeric characters can be used in name and spaces are not allowed. The name should be unique. nthreads Number of threads servicing the task queue. Note that the request ordering is guaranteed (tasks are processed in the order scheduled) if the taskq is created with a single servicing thread. pri Priority of threads servicing the task queue. Drivers and modules should specify TASKQ_DEFAULTPRI. cflags Should pass 0 as flags. func Callback function to call. arg Argument to the callback function. dflags Possible dflags are: DDI_SLEEP Allow sleeping (blocking) until memory is available. DDI_NOSLEEP Return DDI_FAILURE immediately if memory is not available. tq Pointer to a task queue (ddi_taskq_t *). tp Pointer to a thread structure. A kernel task queue is a mechanism for general-purpose asynchronous task scheduling that enables tasks to be performed at a later time by another thread. There are several reasons why you may utilize asynchronous task scheduling: 1. You have a task that isn't time-critical, but a current code path that is. 2. You have a task that may require grabbing locks that a thread already holds. 3. You have a task that needs to block (for example, to wait for memory), but a have a thread that cannot block in its current context. 4. You have a code path that can't complete because of a specific condition, but also can't sleep or fail. In this case, the task is imme- diately queued and then is executed after the condition disappears. 5. A task queue is just a simple way to launch multiple tasks in parallel. A task queue consists of a list of tasks, together with one or more threads to service the list. If a task queue has a single service thread, all tasks are guaranteed to execute in the order they were dispatched. Otherwise they can be executed in any order. Note that since tasks are placed on a list, execution of one task and should not depend on the execution of another task or a deadlock may occur. A taskq created with a single servicing thread guarantees that all the tasks are serviced in the order in which they are scheduled. The ddi_taskq_create() function creates a task queue instance. The ddi_taskq_dispatch() function places taskq on the list for later execution. The dflag argument specifies whether it is allowed sleep waiting for memory. DDI_SLEEP dispatches can sleep and are guaranteed to succeed. DDI_NOSLEEP dispatches are guaranteed not to sleep but may fail (return DDI_FAILURE) if resources are not available. The ddi_taskq_destroy() function waits for any scheduled tasks to complete, then destroys the taskq. The caller should guarantee that no new tasks are scheduled for the closing taskq. The ddi_taskq_wait() function waits for all previously scheduled tasks to complete. Note that this function does not stop any new task dis- patches. The ddi_taskq_suspend() function suspends all task execution until ddi_taskq_resume() is called. Although ddi_taskq_suspend() attempts to suspend pending tasks, there are no guarantees that they will be suspended. The only guarantee is that all tasks dispatched after ddi_taskq_suspend() will not be executed. Because it will trigger a deadlock, the ddi_taskq_suspend() function should never be called by a task executing on a taskq. The ddi_taskq_suspended() function returns B_TRUE if taskq is suspended, and B_FALSE otherwise. It is intended to ASSERT that the task queue is suspended. The ddi_taskq_resume() function resumes task queue execution. RETURN VALUES
The ddi_taskq_create() function creates an opaque handle that is used for all other taskq operations. It returns a taskq pointer on success and NULL on failure. The ddi_taskq_dispatch() function returns DDI_FAILURE if it can't dispatch a task and returns DDI_SUCCESS if dispatch succeeded. The ddi_taskq_suspended() function returns B_TRUE if taskq is suspended. Otherwise B_FALSE is returned. CONTEXT
All functions may be called from the user or kernel contexts. Addtionally, the ddi_taskq_dispatch function may be called from the interrupt context only if the DDI_NOSLEEP flag is set. 1 Mar 2005 taskq(9F)
All times are GMT -4. The time now is 01:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy