How would I delete all recurring tasks in taskwarrior, which are completed, till some date?
I tried:
task Nevena until:07/29/2014 uuids
to get listed those that fall before that date, and collect their id's, so I could pipe them to delete command, but I did not get expected results.
I believe the answer is to delete the parent tasks and then the recurring tasks will no longer get created. You can show all parent tasks with task all +PARENT. For example:
$ task all +PARENT
ID St UUID Age Done Tags R Due Until Description
21 R 58e83c9b 1.7y R 2018-04-01 replace upstairs air filter
20 R f8b5b0db 1.7y [1] R 2018-04-01 replace upstairs air filter
I somehow had two recurring tasks for the same thing. I can delete them:
$ task delete 21
Delete task 21 'replace upstairs air filter'? (yes/no) yes
Deleting task 21 'replace upstairs air filter'.
Deleted 1 task.
$
$ task delete 20
Delete task 20 'replace upstairs air filter'? (yes/no) yes
Deleting task 20 'replace upstairs air filter'.
Deleted 1 task.
Now the recurring tasks shouldn't show up any longer.
I found answer, after pulling my hair for a while (WARNING: This command might also delete tasks which are not recurring):
task $(task uuids due.before:now) delete
did the trick.
This worked, because no matter what the date was, completed tasks had no due date in future, so this command left intact my current fresh tasks with due dates.
The command
task $(task uuids due.before:now +CHILD +COMPLETED) delete
should do exactly what you want.
Based on the answer by #branquito.
Related
Airflow Version : 2.2.5
Composer Version : 2.0.19
We have a task group which creates the tasks dynamically using for loop. Within the taskgroup we are making use of BigQueryTableDeleteOperator to delete the tables.
Issue: We noticed that once the tables are deleted, all the tasks moved to REMOVED state, hence breaking the GANTT chart with error message of Task not found.
Before the task run : Image 1
After the task runs: Image 2
As shown above, before the taskgroup run it shows all the tables to deleted represented by each task . In this example 2 tasks.
Once the task runs into success and the table is deleted, those tasks are removed.
Sharing the piece of code below :
for table in tables_list:
table_name = projectid + '.' + dataset + '.' + table
if table not in safe_tables:
delete_table_task = bigquery_table_delete_operator.BigQueryTableDeleteOperator( task_id=f"delete_tables_{table_name}",
deletion_dataset_table=f"{table_name}",
ignore_if_missing=True)
list_operator += [delete_table_task]
list_operator
print(list_operator)
dummy_task >> list_operator
tables_list : List of tables to be deleted
safe_tables : List of tables not to be deleted
Please let me know what we are missing here which is causing the issue.
Every dag_dir_list_interval, the DagFileProcessorManager list the scripts in the dags folder, then if the script is new or processed since more than the min_file_process_interval, it creates DagFileProcessorProcess for the file to process it and generate the dags.
Since your dag is based on a method which collect the existing tables in tables_list, and use it to create the operators, in the dag file processing just after deleting the tables, the method will return an empty list, and the dag will not have any BigQueryTableDeleteOperator task instance.
For airflow 2.2.5, you can create a new custom operator based on BigQueryTableDeleteOperator which takes the list and delete the tables in a loop, in this case you will have one task for all the tables, and the delete will be run in sequence.
In airflow > 2.3.0 (if the upgrade is an option for you), you can use the new feature Dynamic Task Mapping, which can process a list in runtime, to process each element in a separate task.
You can do something like
BigQueryTableDeleteOperator.partial(
task_id="delete_tables",
ignore_if_missing=True
).expand(
deletion_dataset_table=tables_list
)
I am looking for a way to be able to run a python script at a particular times of day and then have it auto terminated at another time of day. Ideally, I would want this to not be done within the script itself.
For example: I would want the script to start at 08:00 and end at 10:00 then start again at 11:30 and then terminate at 15:00 and I would need this to happen every day automatically.
I have browsed through many suggestions online, and many of them suggested to use cron, however, as far as I can see, cron does not natively offer the functionality of automatically terminating an application.
Others have suggested using cron to start the application at a particular time and then use another cron instance to create a "terminate" file that the program will search for at every loop iteration and if the file is present then the python script will terminate via a sys.exit() function or something, however, this seems quite janky and more of a workaround than a real solution.
You may use Jobber. You will be able to start scripts whenever you want and for the time you want.
Warning : Jobber is not free. You can try it for free though.
Here is the link to Jobber's website.
You could write a script that creates a lockfile with cron (https://unix.stackexchange.com/questions/12815/what-are-pid-and-lock-files-for), and use the lockfile to know what the process ID is, then terminate the process with that id using cron as well
After you have determined that the process name is uniquely identifiable you could do something like this (that's indeed also using cron).
0 8 * * * /path/to/unique_name.py& ( echo "pkill unique_name.py" | at 10:00 )
30 11 * * * /path/to/unique_name.py& ( echo "pkill unique_name.py" | at 15:30 )
Edit 1:
And "name safe" versions (using kill).
0 8 * * * /path/to/unique_name.py& echo kill $! | at 10:00
30 11 * * * /path/to/unique_name.py& echo kill $! | at 15:30
I am using taskwarrior together with conky and to make the format look nicer, I want to modify, what information is actually given by taskwarrior.
In particular, I do not want it to display the "Age" column of a task.
Right now it looks like this:
ID Age Due Description Urg
1 33min 1d Do Stuff 8.33
but I want it to look more like this:
ID Due Description Urg
1 1d Do Stuff 8.33
Is there an easy way of doing this?
Thanks in advance!
Add the following lines to the file ~/.taskrc:
report.report1.description=Report without age attribute
report.report1.columns=id,due,description,urgency
Then you can run task report1 to view the report.
I prefer to edit the default reports. With this command:
task show report
You will get the configuration of all the reports. The default report of task command is report.next, so you can put this in your .taskrc without entry.age:
report.next.columns=id,start.age,depends,priority,project,tags,recur,scheduled.countdown,due.relative,until.remaining,description,urgency
report.next.labels=ID,Active,Deps,P,Project,Tag,Recur,S,Due,Until,Description,Urg
Now the task command will show the next report without the Age.
i am stuck on my code that i am working on and i need some help.
now imagine if you have a list:
[(1,5,7),(2,1,4),(3,0,3),(4,6,10),(5,7,9)]
each one represent a node (ID , start time, finish time)
now i need my output to be:
[(1,5,7),(2,1,4),(5,7,9)]
so that there is no confliction between times.
my code prints:
[(1,5,7),(2,1,4),(3,0,3),(5,7,9)]
and as you can see (3,0,3) conflicts with (2,1,4)
Initialise an empty list for storing busy times.
Use a for loop and go through the list.
When you get the item: 1,5,7. You add all the times between 5 and 7 to that busy times list. So busy times now has 5,6,7.
For each one those node, check if the interval of numbers exist in the busylist. If they don't add them to your non-conflicing selection list, and add those numbers to your busy list.
I'm running this script;
$query = "SELECT * FROM XXX WHERE email='$Email'";
if($count==1) // fails
if($count==0) // succeeds
If successful
mysql_query ("INSERT INTO XXX (email) values ('$Email'");
Then proceeds onto the next script.
So, it checks to see if you have already ran this script in the past on that account, if you have your email is stored then you can't run this script ever again on that same email.
However, after this script has been processed I want it to delete the row created for the email after 6 hours.
So that after 6 hours they may run the script again.. I've been enlightened that I need to use Cron jobs for this, But I'm not sure how.. Any help is highly appreciated!
Many regards, and thanks in advance.
0 0,6,12,18 * * * /path/to/mycommand
This means starting from hour 0, 6, 12, and 18 the cron job would run. That would be the cron needed to do what you want.
Depending on which linux version you are running you will need to see how to actually create the cron job.
I would think at now +6 hours is a better choice here.